Files
gocryptotrader/log/custom_log_hooks.go
Ryan O'Hara-Reid db59b8540e log: allow external definition of log handling (#1561)
* poc

* linter: fix

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-07-19 10:10:27 +10:00

18 lines
630 B
Go

package log
// CustomLogHook is a function type for external log handling. It should return
// true if the library's internal logging system should be bypassed, or false
// if the library's internal logging system should be used.
type CustomLogHook func(header, subLoggerName string, a ...any) (bypassLibraryLogSystem bool)
var customLogHook CustomLogHook
// SetCustomLogHook sets a custom log hook function that allows the complete
// bypass of the library's internal logging system. This is useful for
// implementing custom log handling.
func SetCustomLogHook(h CustomLogHook) {
mu.Lock()
customLogHook = h
mu.Unlock()
}