mirror of https://github.com/sirupsen/logrus.git
Merge pull request #779 from daskol/iss-241
[#241] Allow to set writer during logger usage.
This commit is contained in:
commit
e54a77765a
|
@ -15,9 +15,7 @@ func StandardLogger() *Logger {
|
||||||
|
|
||||||
// SetOutput sets the standard logger output.
|
// SetOutput sets the standard logger output.
|
||||||
func SetOutput(out io.Writer) {
|
func SetOutput(out io.Writer) {
|
||||||
std.mu.Lock()
|
std.SetOutput(out)
|
||||||
defer std.mu.Unlock()
|
|
||||||
std.Out = out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFormatter sets the standard logger formatter.
|
// SetFormatter sets the standard logger formatter.
|
||||||
|
|
|
@ -316,6 +316,12 @@ func (logger *Logger) SetLevel(level Level) {
|
||||||
atomic.StoreUint32((*uint32)(&logger.Level), uint32(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) {
|
func (logger *Logger) AddHook(hook Hook) {
|
||||||
logger.mu.Lock()
|
logger.mu.Lock()
|
||||||
defer logger.mu.Unlock()
|
defer logger.mu.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue