Skip to content

Commit

Permalink
Improve logging functionality and data type conversion
Browse files Browse the repository at this point in the history
- Add `String()` method to `DataType` enum in types.go
- Update log level to Debug in logger_test.go
- Set log level to Debug in `TestLoggerDebug` and `TestLoggerDebugf` functions
  • Loading branch information
moonD4rk committed Oct 22, 2024
1 parent aa45e2d commit 4499f01
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestLoggerDebug(t *testing.T) {
t.Run(tc.description, func(t *testing.T) {
var buf bytes.Buffer
logger := NewLogger(newBase(&buf))
logger.SetLevel(level2.DebugLevel)
logger.Debug(message)
got := buf.String()
assert.Regexp(t, tc.wantedPattern, got)
Expand Down Expand Up @@ -149,6 +150,7 @@ func TestLoggerDebugf(t *testing.T) {
t.Run(tc.description, func(t *testing.T) {
var buf bytes.Buffer
logger := NewLogger(newBase(&buf))
logger.SetLevel(level2.DebugLevel)
logger.Debugf(tc.format, tc.args...)
got := buf.String()
assert.Regexp(t, tc.wantedPattern, got)
Expand Down
51 changes: 51 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,57 @@ var itemFileNames = map[DataType]string{
FirefoxCreditCard: UnsupportedItem,
}

func (i DataType) String() string {
switch i {
case ChromiumKey:
return "ChromiumKey"
case ChromiumPassword:
return "ChromiumPassword"
case ChromiumCookie:
return "ChromiumCookie"
case ChromiumBookmark:
return "ChromiumBookmark"
case ChromiumHistory:
return "ChromiumHistory"
case ChromiumDownload:
return "ChromiumDownload"
case ChromiumCreditCard:
return "ChromiumCreditCard"
case ChromiumLocalStorage:
return "ChromiumLocalStorage"
case ChromiumSessionStorage:
return "ChromiumSessionStorage"
case ChromiumExtension:
return "ChromiumExtension"
case YandexPassword:
return "YandexPassword"
case YandexCreditCard:
return "YandexCreditCard"
case FirefoxKey4:
return "FirefoxKey4"
case FirefoxPassword:
return "FirefoxPassword"
case FirefoxCookie:
return "FirefoxCookie"
case FirefoxBookmark:
return "FirefoxBookmark"
case FirefoxHistory:
return "FirefoxHistory"
case FirefoxDownload:
return "FirefoxDownload"
case FirefoxCreditCard:
return "FirefoxCreditCard"
case FirefoxLocalStorage:
return "FirefoxLocalStorage"
case FirefoxSessionStorage:
return "FirefoxSessionStorage"
case FirefoxExtension:
return "FirefoxExtension"
default:
return "UnsupportedItem"
}
}

// Filename returns the filename for the item, defined by browser
// chromium local storage is a folder, so it returns the file name of the folder
func (i DataType) Filename() string {
Expand Down

0 comments on commit 4499f01

Please sign in to comment.