mirror of
https://github.com/moonD4rk/HackBrowserData
synced 2025-04-07 01:31:24 +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"
|
"github.com/moond4rk/hackbrowserdata/log/level"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// defaultLogger is the default logger used by the package-level functions.
|
// defaultLogger is the default logger used by the package-level functions.
|
||||||
defaultLogger = NewLogger(nil)
|
var defaultLogger = NewLogger(nil)
|
||||||
)
|
|
||||||
|
|
||||||
func SetVerbose() {
|
func SetVerbose() {
|
||||||
defaultLogger.SetLevel(level.DebugLevel)
|
defaultLogger.SetLevel(level.DebugLevel)
|
||||||
|
@ -136,7 +136,7 @@ func (l *baseLogger) prefixPrint(prefix string, args ...any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *baseLogger) getCallDepth() int {
|
func (l *baseLogger) getCallDepth() int {
|
||||||
var defaultCallDepth = 2
|
defaultCallDepth := 2
|
||||||
pcs := make([]uintptr, 10)
|
pcs := make([]uintptr, 10)
|
||||||
n := runtime.Callers(defaultCallDepth, pcs)
|
n := runtime.Callers(defaultCallDepth, pcs)
|
||||||
frames := runtime.CallersFrames(pcs[:n])
|
frames := runtime.CallersFrames(pcs[:n])
|
||||||
|
@ -22,8 +22,7 @@ type baseTestCase struct {
|
|||||||
wantedPattern string
|
wantedPattern string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var baseTestCases = []baseTestCase{
|
||||||
baseTestCases = []baseTestCase{
|
|
||||||
{
|
{
|
||||||
description: "without trailing newline, logger adds newline",
|
description: "without trailing newline, logger adds newline",
|
||||||
message: "hello, hacker!",
|
message: "hello, hacker!",
|
||||||
@ -35,7 +34,6 @@ var (
|
|||||||
suffix: "\n",
|
suffix: "\n",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
func TestLoggerDebug(t *testing.T) {
|
func TestLoggerDebug(t *testing.T) {
|
||||||
for _, tc := range baseTestCases {
|
for _, tc := range baseTestCases {
|
||||||
@ -121,8 +119,7 @@ type formatTestCase struct {
|
|||||||
wantedPattern string
|
wantedPattern string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var formatTestCases = []formatTestCase{
|
||||||
formatTestCases = []formatTestCase{
|
|
||||||
{
|
{
|
||||||
description: "message with format prefix",
|
description: "message with format prefix",
|
||||||
format: "hello, %s!",
|
format: "hello, %s!",
|
||||||
@ -139,7 +136,6 @@ var (
|
|||||||
args: []any{"Hacker", 2, 3},
|
args: []any{"Hacker", 2, 3},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
func TestLoggerDebugf(t *testing.T) {
|
func TestLoggerDebugf(t *testing.T) {
|
||||||
for _, tc := range formatTestCases {
|
for _, tc := range formatTestCases {
|
||||||
|
@ -41,9 +41,7 @@ func (m *Finder) FindProfiles(rootPath string, browserType types2.BrowserType, d
|
|||||||
return profiles, nil
|
return profiles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var defaultExcludeDirs = []string{"Snapshot", "System Profile", "Crash Reports", "def"}
|
||||||
defaultExcludeDirs = []string{"Snapshot", "System Profile", "Crash Reports", "def"}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (m *Finder) findChromiumProfiles(rootPath string, browserType types2.BrowserType, dataTypes []types2.DataType) (Profiles, error) {
|
func (m *Finder) findChromiumProfiles(rootPath string, browserType types2.BrowserType, dataTypes []types2.DataType) (Profiles, error) {
|
||||||
profiles := NewProfiles()
|
profiles := NewProfiles()
|
||||||
|
@ -138,5 +138,4 @@ func Test_extractProfileNameFromPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user