Skip to content

Commit

Permalink
Add get level method
Browse files Browse the repository at this point in the history
  • Loading branch information
leodeim committed Dec 22, 2023
1 parent 555c433 commit 606704d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
type Logger interface {
NewLocal(opts ...Op) Logger
SetLevel(level Level) error
Level() Level
Close()
Info() *message
Error() *message
Expand All @@ -37,6 +38,14 @@ var levels = map[Level]int{
Fatal: 4,
}

var levelsRev = map[int]Level{
0: Debug,
1: Info,
2: Warning,
3: Error,
4: Fatal,
}

const (
DefaultLevel = Info
DefaultName = "<...>"
Expand Down Expand Up @@ -192,6 +201,15 @@ func (l *log) SetLevel(level Level) error {
return nil
}

// Get log level for current logger instance
func (l *log) Level() Level {
if v, ok := levelsRev[l.local.level]; ok {
return v
}

return ""
}

// Close logger, should be closed before application exit in case of non blocking mode
func (l *log) Close() {
defer func() {
Expand Down

0 comments on commit 606704d

Please sign in to comment.