mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
da20785685
Former-commit-id: 23f542f43b4b493e38f5aa4c29788ed93a63b43b [formerly 71b23a6a28eb045fcfeab6329de69f1e5455486b] Former-commit-id: d12b3a6decc876f010a71f98e11df7387c1aaf2a
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package log
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
var (
|
|
root = &logger{[]interface{}{}, new(swapHandler)}
|
|
StdoutHandler = StreamHandler(os.Stdout, LogfmtFormat())
|
|
StderrHandler = StreamHandler(os.Stderr, LogfmtFormat())
|
|
)
|
|
|
|
func init() {
|
|
root.SetHandler(DiscardHandler())
|
|
}
|
|
|
|
// New returns a new logger with the given context.
|
|
// New is a convenient alias for Root().New
|
|
func New(ctx ...interface{}) Logger {
|
|
return root.New(ctx...)
|
|
}
|
|
|
|
// Root returns the root logger
|
|
func Root() Logger {
|
|
return root
|
|
}
|
|
|
|
// The following functions bypass the exported logger methods (logger.Debug,
|
|
// etc.) to keep the call depth the same for all paths to logger.write so
|
|
// runtime.Caller(2) always refers to the call site in client code.
|
|
|
|
// Trace is a convenient alias for Root().Trace
|
|
func Trace(msg string, ctx ...interface{}) {
|
|
root.write(msg, LvlTrace, ctx)
|
|
}
|
|
|
|
// Debug is a convenient alias for Root().Debug
|
|
func Debug(msg string, ctx ...interface{}) {
|
|
root.write(msg, LvlDebug, ctx)
|
|
}
|
|
|
|
// Info is a convenient alias for Root().Info
|
|
func Info(msg string, ctx ...interface{}) {
|
|
root.write(msg, LvlInfo, ctx)
|
|
}
|
|
|
|
// Warn is a convenient alias for Root().Warn
|
|
func Warn(msg string, ctx ...interface{}) {
|
|
root.write(msg, LvlWarn, ctx)
|
|
}
|
|
|
|
// Error is a convenient alias for Root().Error
|
|
func Error(msg string, ctx ...interface{}) {
|
|
root.write(msg, LvlError, ctx)
|
|
}
|
|
|
|
// Crit is a convenient alias for Root().Crit
|
|
func Crit(msg string, ctx ...interface{}) {
|
|
root.write(msg, LvlCrit, ctx)
|
|
os.Exit(1)
|
|
}
|