Skip to content

Commit

Permalink
Merge 07729a7 into 920ccb4
Browse files Browse the repository at this point in the history
  • Loading branch information
martinilevi committed Mar 27, 2018
2 parents 920ccb4 + 07729a7 commit 7df4afb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ func NewLogger() *Logger {
}
}


// NewLoggerWithOutput to create a Logger to a different output than stdout.
func NewLoggerWithOutput(o io.Writer) *Logger {
return &Logger{
out: o,
logLevel: defaultLogLevel,
}
}

// SetDefaultLogLevel sets the default log level. This default can be overridden with SetLevel method.
func SetDefaultLogLevel(level string) {
defaultLogLevel = levelByName(level)
Expand All @@ -100,6 +109,16 @@ func (l *Logger) GetLevel() string {
return LogLevelNames[l.logLevel]
}

// SetOutput to set the log writer
func (l *Logger) SetOutput(o io.Writer) {
l.out = o
}

// GetOutput to get the log writer
func (l *Logger) GetOutput() io.Writer {
return l.out
}

func (l *Logger) log(logLevel level, context interface{}, message string, args ...interface{}) {
if logLevel >= l.logLevel {
var buf bytes.Buffer
Expand Down

0 comments on commit 7df4afb

Please sign in to comment.