[#241] Allow to set writer during logger usage.

This commit is contained in:
Daniel Bershatsky 2018-06-27 20:29:28 +03:00
parent e3292c4c4d
commit fc9bbf2f57
2 changed files with 7 additions and 3 deletions

View File

@ -15,9 +15,7 @@ func StandardLogger() *Logger {
// SetOutput sets the standard logger output.
func SetOutput(out io.Writer) {
std.mu.Lock()
defer std.mu.Unlock()
std.Out = out
std.SetOutput(out)
}
// SetFormatter sets the standard logger formatter.

View File

@ -316,6 +316,12 @@ func (logger *Logger) SetLevel(level Level) {
atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
}
func (logger *Logger) SetOutput(out io.Writer) {
logger.mu.Lock()
defer logger.mu.Unlock()
logger.Out = out
}
func (logger *Logger) AddHook(hook Hook) {
logger.mu.Lock()
defer logger.mu.Unlock()