Skip to content

Commit

Permalink
all: legacy trace log
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Oct 1, 2024
1 parent 86e7acf commit a79518e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
16 changes: 2 additions & 14 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ const (
ERROR
INFO
DEBUG
TRACE
)

// String implements fmt.Stringer for Level
func (l Level) String() string {
switch l {
case TRACE:
return "trace"
case DEBUG:
return "debug"
case INFO:
Expand Down Expand Up @@ -182,20 +179,13 @@ func Debug(format string, args ...any) {
}
}

// Debugf writes to debug log and adds the calling function's name.
func Debugf(format string, args ...any) {
// Tracef writes to debug log and adds the calling function's name
func Tracef(format string, args ...any) {
if atomic.LoadUint32(&level) >= uint32(DEBUG) {
writeLog("debug", getCallerName(), format, args...)
}
}

// Trace writes to trace log.
func Trace(format string, args ...any) {
if atomic.LoadUint32(&level) >= uint32(TRACE) {
writeLog("trace", "", format, args...)
}
}

// Get goroutine ID
// (https://blog.sgmansfield.com/2015/12/goroutine-ids/)
func goroutineID() uint64 {
Expand Down Expand Up @@ -266,8 +256,6 @@ func (w *stdLogWriter) Write(p []byte) (n int, err error) {
logFunc = Debug
case INFO:
logFunc = Info
case TRACE:
logFunc = Trace
}

if prefix := w.prefix; prefix == "" {
Expand Down
2 changes: 1 addition & 1 deletion logutil/slogutil/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ type logFunction func(format string, args ...any)
func logFuncForLevel(lvl slog.Level) (logFunc logFunction, warnStr string, err error) {
switch lvl {
case LevelTrace:
return aglog.Trace, "", nil
return aglog.Debug, "trace: ", nil
case slog.LevelDebug:
return aglog.Debug, "", nil
case slog.LevelInfo:
Expand Down

0 comments on commit a79518e

Please sign in to comment.