Skip to content

Commit

Permalink
export Level variable
Browse files Browse the repository at this point in the history
  • Loading branch information
wongoo committed Oct 12, 2019
1 parent c933d4d commit fa171e5
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ const (
)

var (
level = LevelInfo
Level = LevelInfo
output io.Writer = os.Stdout
lock sync.Mutex
flag int
)

// SetLevel set logger level
// SetLevel set logger Level
// the Level variable is exported and can be set directly.
func SetLevel(l int) {
level = l
Level = l
}

// SetOutput set logger output writer
Expand All @@ -66,70 +67,70 @@ func Writer() io.Writer {
}

func Trace(a ...interface{}) {
if level < LevelTrace {
if Level < LevelTrace {
return
}
WriteLog(TagTrace, fmt.Sprint(a...))
}

func Debug(a ...interface{}) {
if level < LevelDebug {
if Level < LevelDebug {
return
}
WriteLog(TagDebug, fmt.Sprint(a...))
}

func Info(a ...interface{}) {
if level < LevelInfo {
if Level < LevelInfo {
return
}
WriteLog(TagInfo, fmt.Sprint(a...))
}

func Warn(a ...interface{}) {
if level < LevelWarn {
if Level < LevelWarn {
return
}
WriteLog(TagWarn, fmt.Sprint(a...))
}

func Error(a ...interface{}) {
if level < LevelError {
if Level < LevelError {
return
}
WriteLog(TagError, fmt.Sprint(a...))
}

func Tracef(format string, a ...interface{}) {
if level < LevelTrace {
if Level < LevelTrace {
return
}
WriteLog(TagTrace, fmt.Sprintf(format, a...))
}

func Debugf(format string, a ...interface{}) {
if level < LevelDebug {
if Level < LevelDebug {
return
}
WriteLog(TagDebug, fmt.Sprintf(format, a...))
}

func Infof(format string, a ...interface{}) {
if level < LevelInfo {
if Level < LevelInfo {
return
}
WriteLog(TagInfo, fmt.Sprintf(format, a...))
}

func Warnf(format string, a ...interface{}) {
if level < LevelWarn {
if Level < LevelWarn {
return
}
WriteLog(TagWarn, fmt.Sprintf(format, a...))
}

func Errorf(format string, a ...interface{}) {
if level < LevelError {
if Level < LevelError {
return
}
WriteLog(TagError, fmt.Sprintf(format, a...))
Expand Down

0 comments on commit fa171e5

Please sign in to comment.