为什么没有在日志包中使用锁同步

时间:2016-01-20 16:04:38

标签: logging go

我正在阅读log source code,我在这里感到困惑:

 driver.findElement(By.id("asd")).sendKeys("01");

为什么// SetOutput sets the output destination for the standard logger. func SetOutput(w io.Writer) { std.mu.Lock() defer std.mu.Unlock() std.out = w } // Flags returns the output flags for the standard logger. func Flags() int { return std.Flags() } // SetFlags sets the output flags for the standard logger. func SetFlags(flag int) { std.SetFlags(flag) } 使用SetOutPut锁定但mu不使用SetFlags锁定?

1 个答案:

答案 0 :(得分:3)

SetOutput正在改变std默认记录器的内部状态。

log.SetFlags正在std上调用SetFlags,它已经锁定了记录器本身。

相关问题