Skip to content

Commit

Permalink
Added instance methods for logger to operate on custom logging instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Djadih committed May 23, 2023
1 parent f97f95d commit 786cfee
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,56 @@ func New(out_path string) Logger {
return Logger{logger}
}

// Uses of the global logger will use the following static method.
func Trace(msg string, args ...interface{}) {
Log.Trace(constructLogMessage(msg, args...))
}
// Individual logging instances will use the following method.
func (l Logger) Trace(msg string, args ...interface{}) {
l.Logger.Trace(constructLogMessage(msg, args...))
}

func Debug(msg string, args ...interface{}) {
Log.Debug(constructLogMessage(msg, args...))
}
func (l Logger) Debug(msg string, args ...interface{}) {
l.Logger.Debug(constructLogMessage(msg, args...))
}

func Info(msg string, args ...interface{}) {
Log.Info(constructLogMessage(msg, args...))
}
func (l Logger) Info(msg string, args ...interface{}) {
l.Logger.Info(constructLogMessage(msg, args...))
}

func Warn(msg string, args ...interface{}) {
Log.Warn(constructLogMessage(msg, args...))
}
func (l Logger) Warn(msg string, args ...interface{}) {
l.Logger.Warn(constructLogMessage(msg, args...))
}

func Error(msg string, args ...interface{}) {
Log.Error(constructLogMessage(msg, args...))
}
func (l Logger) Error(msg string, args ...interface{}) {
l.Logger.Error(constructLogMessage(msg, args...))
}

func Fatal(msg string, args ...interface{}) {
Log.Fatal(constructLogMessage(msg, args...))
}
func (l Logger) Fatal(msg string, args ...interface{}) {
l.Logger.Fatal(constructLogMessage(msg, args...))
}

func Panic(msg string, args ...interface{}) {
Log.Panic(constructLogMessage(msg, args...))
}
func (l Logger) Panic(msg string, args ...interface{}) {
l.Logger.Panic(constructLogMessage(msg, args...))
}

func Lazy(fn func() string, logLevel string) {
level, err := logrus.ParseLevel(logLevel)
Expand Down

0 comments on commit 786cfee

Please sign in to comment.