refactor: redesign logging system for CLI-friendly output (#561)

* refactor: redesign logging system for CLI-friendly output
* refactor: remove ANSI color support from logger
* fix: address PR review feedback
This commit is contained in:
Roger
2026-04-07 16:50:01 +08:00
committed by GitHub
parent a0b4412bf2
commit 5f42d4fe5f
13 changed files with 287 additions and 199 deletions
+7 -1
View File
@@ -16,6 +16,8 @@ const defaultCookieQuery = `SELECT name, encrypted_value, host_key, path,
has_expires, is_persistent FROM cookies`
func extractCookies(masterKey []byte, path string) ([]types.CookieEntry, error) {
var decryptFails int
var lastErr error
cookies, err := sqliteutil.QueryRows(path, false, defaultCookieQuery,
func(rows *sql.Rows) (types.CookieEntry, error) {
var (
@@ -33,7 +35,8 @@ func extractCookies(masterKey []byte, path string) ([]types.CookieEntry, error)
value, err := decryptValue(masterKey, encryptedValue)
if err != nil {
log.Debugf("decrypt cookie %s on %s: %v", name, host, err)
decryptFails++
lastErr = err
}
value = stripCookieHash(value, host)
return types.CookieEntry{
@@ -52,6 +55,9 @@ func extractCookies(masterKey []byte, path string) ([]types.CookieEntry, error)
if err != nil {
return nil, err
}
if decryptFails > 0 {
log.Debugf("decrypt cookies: %d failed: %v", decryptFails, lastErr)
}
sort.Slice(cookies, func(i, j int) bool {
return cookies[i].CreatedAt.After(cookies[j].CreatedAt)