Documentation ¶
Overview ¶
Package logger has helpers to setup a zerolog.Logger
https://github.com/rs/zerolog
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger is a convenience function to initialize a zerolog.Logger
Example ¶
package main import ( "os" "github.com/gilcrest/httplog/logger" "github.com/rs/zerolog" ) func main() { lgr := logger.NewLogger(os.Stdout, zerolog.DebugLevel, false) lgr.Trace().Msg("Trace is lower than Debug, this message is filtered out") lgr.Debug().Msg("This is a log at the Debug level") zerolog.SetGlobalLevel(zerolog.ErrorLevel) lgr.Debug().Msg("Logging level raised to Error, Debug is lower than Error, this message is filtered out") lgr.Error().Msg("This is a log at the Error level") zerolog.SetGlobalLevel(zerolog.TraceLevel) lgr.Trace().Msg("Setting Global level will not impact minimum set to logger, this trace message will still be filtered out") lgr.Debug().Msg("Logging level raised all the way down to Trace level, Debug is higher than Trace, this will log") }
Output: {"level":"debug","severity":"DEBUG","message":"This is a log at the Debug level"} {"level":"error","severity":"ERROR","message":"This is a log at the Error level"} {"level":"debug","severity":"DEBUG","message":"Logging level raised all the way down to Trace level, Debug is higher than Trace, this will log"}
func WriteErrorStackGlobal ¶
func WriteErrorStackGlobal(writeStack bool)
WriteErrorStackGlobal is a convenience wrapper to set the zerolog Global variable ErrorStackMarshaler to write Error stacks for logs
Types ¶
type GCPSeverityHook ¶
type GCPSeverityHook struct{}
The GCPSeverityHook struct satisfies the zerolog.Hook interface as it has the Run method defined with the appropriate parameters
Click to show internal directories.
Click to hide internal directories.