github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/chain/log/handler_go14.go (about) 1 //go:build go1.4 2 // +build go1.4 3 4 package log 5 6 import "sync/atomic" 7 8 type swapHandler struct { 9 handler atomic.Value 10 } 11 12 func (h *swapHandler) Log(r *Record) error { 13 return (*h.handler.Load().(*Handler)).Log(r) 14 } 15 16 func (h *swapHandler) Swap(newHandler Handler) { 17 h.handler.Store(&newHandler) 18 } 19 20 func (h *swapHandler) Get() Handler { 21 return *h.handler.Load().(*Handler) 22 }