github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/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  }