mirror of
https://github.com/moonD4rk/HackBrowserData
synced 2025-03-30 23:26:27 +00:00
refactor: Refactor logging and profile handling functionalities
- Refactored variable declarations in log package for improved readability and consistency - Removed redundant code and unnecessary parentheses in logger_test.go - Simplified variable assignment in logger.go for better code maintainability
This commit is contained in:
parent
28280220d1
commit
faf988d1c1
@ -4,10 +4,8 @@ import (
|
||||
"github.com/moond4rk/hackbrowserdata/log/level"
|
||||
)
|
||||
|
||||
var (
|
||||
// defaultLogger is the default logger used by the package-level functions.
|
||||
defaultLogger = NewLogger(nil)
|
||||
)
|
||||
// defaultLogger is the default logger used by the package-level functions.
|
||||
var defaultLogger = NewLogger(nil)
|
||||
|
||||
func SetVerbose() {
|
||||
defaultLogger.SetLevel(level.DebugLevel)
|
||||
|
@ -136,7 +136,7 @@ func (l *baseLogger) prefixPrint(prefix string, args ...any) {
|
||||
}
|
||||
|
||||
func (l *baseLogger) getCallDepth() int {
|
||||
var defaultCallDepth = 2
|
||||
defaultCallDepth := 2
|
||||
pcs := make([]uintptr, 10)
|
||||
n := runtime.Callers(defaultCallDepth, pcs)
|
||||
frames := runtime.CallersFrames(pcs[:n])
|
||||
|
@ -22,20 +22,18 @@ type baseTestCase struct {
|
||||
wantedPattern string
|
||||
}
|
||||
|
||||
var (
|
||||
baseTestCases = []baseTestCase{
|
||||
{
|
||||
description: "without trailing newline, logger adds newline",
|
||||
message: "hello, hacker!",
|
||||
suffix: "",
|
||||
},
|
||||
{
|
||||
description: "with trailing newline, logger preserves newline",
|
||||
message: "hello, hacker!",
|
||||
suffix: "\n",
|
||||
},
|
||||
}
|
||||
)
|
||||
var baseTestCases = []baseTestCase{
|
||||
{
|
||||
description: "without trailing newline, logger adds newline",
|
||||
message: "hello, hacker!",
|
||||
suffix: "",
|
||||
},
|
||||
{
|
||||
description: "with trailing newline, logger preserves newline",
|
||||
message: "hello, hacker!",
|
||||
suffix: "\n",
|
||||
},
|
||||
}
|
||||
|
||||
func TestLoggerDebug(t *testing.T) {
|
||||
for _, tc := range baseTestCases {
|
||||
@ -121,25 +119,23 @@ type formatTestCase struct {
|
||||
wantedPattern string
|
||||
}
|
||||
|
||||
var (
|
||||
formatTestCases = []formatTestCase{
|
||||
{
|
||||
description: "message with format prefix",
|
||||
format: "hello, %s!",
|
||||
args: []any{"Hacker"},
|
||||
},
|
||||
{
|
||||
description: "message with format prefix",
|
||||
format: "hello, %d,%d,%d!",
|
||||
args: []any{1, 2, 3},
|
||||
},
|
||||
{
|
||||
description: "message with format prefix",
|
||||
format: "hello, %s,%d,%d!",
|
||||
args: []any{"Hacker", 2, 3},
|
||||
},
|
||||
}
|
||||
)
|
||||
var formatTestCases = []formatTestCase{
|
||||
{
|
||||
description: "message with format prefix",
|
||||
format: "hello, %s!",
|
||||
args: []any{"Hacker"},
|
||||
},
|
||||
{
|
||||
description: "message with format prefix",
|
||||
format: "hello, %d,%d,%d!",
|
||||
args: []any{1, 2, 3},
|
||||
},
|
||||
{
|
||||
description: "message with format prefix",
|
||||
format: "hello, %s,%d,%d!",
|
||||
args: []any{"Hacker", 2, 3},
|
||||
},
|
||||
}
|
||||
|
||||
func TestLoggerDebugf(t *testing.T) {
|
||||
for _, tc := range formatTestCases {
|
||||
|
@ -41,9 +41,7 @@ func (m *Finder) FindProfiles(rootPath string, browserType types2.BrowserType, d
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
var (
|
||||
defaultExcludeDirs = []string{"Snapshot", "System Profile", "Crash Reports", "def"}
|
||||
)
|
||||
var defaultExcludeDirs = []string{"Snapshot", "System Profile", "Crash Reports", "def"}
|
||||
|
||||
func (m *Finder) findChromiumProfiles(rootPath string, browserType types2.BrowserType, dataTypes []types2.DataType) (Profiles, error) {
|
||||
profiles := NewProfiles()
|
||||
|
@ -138,5 +138,4 @@ func Test_extractProfileNameFromPath(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user