Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logger): call depth for logging events #97

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ linters:

issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
- unparam
- prealloc
- funlen
- path: logger/simple_logger.go
linters:
- errcheck
21 changes: 11 additions & 10 deletions logger/simple_logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package logger

import (
"fmt"
"log"
)

Expand Down Expand Up @@ -34,7 +35,7 @@ func NewSimpleLogger(logger *log.Logger, level Level) *SimpleLogger {
func (l *SimpleLogger) Trace(msg any) {
if l.Enabled(LevelTrace) {
l.logger.SetPrefix(TracePrefix)
l.logger.Println(msg)
l.logger.Output(3, fmt.Sprint(msg))
}
}

Expand All @@ -43,7 +44,7 @@ func (l *SimpleLogger) Trace(msg any) {
func (l *SimpleLogger) Tracef(format string, args ...any) {
if l.Enabled(LevelTrace) {
l.logger.SetPrefix(TracePrefix)
l.logger.Printf(format, args...)
l.logger.Output(3, fmt.Sprintf(format, args...))
}
}

Expand All @@ -52,7 +53,7 @@ func (l *SimpleLogger) Tracef(format string, args ...any) {
func (l *SimpleLogger) Debug(msg any) {
if l.Enabled(LevelDebug) {
l.logger.SetPrefix(DebugPrefix)
l.logger.Println(msg)
l.logger.Output(3, fmt.Sprint(msg))
}
}

Expand All @@ -61,7 +62,7 @@ func (l *SimpleLogger) Debug(msg any) {
func (l *SimpleLogger) Debugf(format string, args ...any) {
if l.Enabled(LevelDebug) {
l.logger.SetPrefix(DebugPrefix)
l.logger.Printf(format, args...)
l.logger.Output(3, fmt.Sprintf(format, args...))
}
}

Expand All @@ -70,7 +71,7 @@ func (l *SimpleLogger) Debugf(format string, args ...any) {
func (l *SimpleLogger) Info(msg any) {
if l.Enabled(LevelInfo) {
l.logger.SetPrefix(InfoPrefix)
l.logger.Println(msg)
l.logger.Output(3, fmt.Sprint(msg))
}
}

Expand All @@ -79,7 +80,7 @@ func (l *SimpleLogger) Info(msg any) {
func (l *SimpleLogger) Infof(format string, args ...any) {
if l.Enabled(LevelInfo) {
l.logger.SetPrefix(InfoPrefix)
l.logger.Printf(format, args...)
l.logger.Output(3, fmt.Sprintf(format, args...))
}
}

Expand All @@ -88,7 +89,7 @@ func (l *SimpleLogger) Infof(format string, args ...any) {
func (l *SimpleLogger) Warn(msg any) {
if l.Enabled(LevelWarn) {
l.logger.SetPrefix(WarnPrefix)
l.logger.Println(msg)
l.logger.Output(3, fmt.Sprint(msg))
}
}

Expand All @@ -97,7 +98,7 @@ func (l *SimpleLogger) Warn(msg any) {
func (l *SimpleLogger) Warnf(format string, args ...any) {
if l.Enabled(LevelWarn) {
l.logger.SetPrefix(WarnPrefix)
l.logger.Printf(format, args...)
l.logger.Output(3, fmt.Sprintf(format, args...))
}
}

Expand All @@ -106,7 +107,7 @@ func (l *SimpleLogger) Warnf(format string, args ...any) {
func (l *SimpleLogger) Error(msg any) {
if l.Enabled(LevelError) {
l.logger.SetPrefix(ErrorPrefix)
l.logger.Println(msg)
l.logger.Output(3, fmt.Sprint(msg))
}
}

Expand All @@ -115,7 +116,7 @@ func (l *SimpleLogger) Error(msg any) {
func (l *SimpleLogger) Errorf(format string, args ...any) {
if l.Enabled(LevelError) {
l.logger.SetPrefix(ErrorPrefix)
l.logger.Printf(format, args...)
l.logger.Output(3, fmt.Sprintf(format, args...))
}
}

Expand Down
Loading