@ -358,19 +358,9 @@ func errorTextSync(msg string) {
}
func getWriter() Writer {
var w Writer
writer.lock.RLock()
w = writer.writer
writer.lock.RUnlock()
w := writer.Load()
if w == nil {
writer.lock.Lock()
if writer.writer == nil {
writer.writer = newConsoleWriter()
writer.lock.Unlock()
w = writer.StoreIfNil(newConsoleWriter())
return w
@ -67,6 +67,17 @@ func (w *atomicWriter) Store(v Writer) {
w.writer = v
func (w *atomicWriter) StoreIfNil(v Writer) Writer {
w.lock.Lock()
defer w.lock.Unlock()
if w.writer == nil {
return w.writer
func (w *atomicWriter) Swap(v Writer) Writer {