Skip to content

Commit

Permalink
Merge pull request #56 from w-h-a/log-level
Browse files Browse the repository at this point in the history
fix: log level
  • Loading branch information
w-h-a authored Aug 8, 2024
2 parents 35fb019 + 4c218b7 commit 28d00a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions telemetry/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ func WithLevel(l Level, v ...interface{}) {
if l > level {
return
}
log(v...)
log(l, v...)
}

// WithLevel logs with the level specified
func WithLevelf(l Level, format string, v ...interface{}) {
if l > level {
return
}
logf(format, v...)
logf(l, format, v...)
}

func log(v ...interface{}) {
func log(l Level, v ...interface{}) {
if len(prefix) > 0 {
v = append([]interface{}{prefix, " "}, v...)
}
Expand All @@ -138,12 +138,12 @@ func log(v ...interface{}) {
Record{
Timestamp: time.Now(),
Message: fmt.Sprint(v...),
Metadata: map[string]string{"level": level.String()},
Metadata: map[string]string{"level": l.String()},
},
)
}

func logf(format string, v ...interface{}) {
func logf(l Level, format string, v ...interface{}) {
if len(prefix) > 0 {
format = prefix + " " + format
}
Expand All @@ -152,7 +152,7 @@ func logf(format string, v ...interface{}) {
Record{
Timestamp: time.Now(),
Message: fmt.Sprintf(format, v...),
Metadata: map[string]string{"level": level.String()},
Metadata: map[string]string{"level": l.String()},
},
)
}

0 comments on commit 28d00a0

Please sign in to comment.