Documentation
¶
Index ¶
- Constants
- func DisableGRPCLog()
- func Discard()
- func GinLogger(server string) gin.HandlerFunc
- func RequestID(ctx context.Context) (string, bool)
- func ResetLogger()
- func Testing(tb testing.TB)
- func Tracing(ctx context.Context) zerolog.Logger
- func WithRequestID(parent context.Context, requestID string) context.Context
- type LevelDecoder
- type SeverityHook
- type ZeroGRPCV2
- func (g *ZeroGRPCV2) Error(args ...interface{})
- func (g *ZeroGRPCV2) Errorf(format string, args ...interface{})
- func (g *ZeroGRPCV2) Errorln(args ...interface{})
- func (g *ZeroGRPCV2) Fatal(args ...interface{})
- func (g *ZeroGRPCV2) Fatalf(format string, args ...interface{})
- func (g *ZeroGRPCV2) Fatalln(args ...interface{})
- func (g *ZeroGRPCV2) Info(args ...interface{})
- func (g *ZeroGRPCV2) Infof(format string, args ...interface{})
- func (g *ZeroGRPCV2) Infoln(args ...interface{})
- func (g *ZeroGRPCV2) V(l int) bool
- func (g *ZeroGRPCV2) Warning(args ...interface{})
- func (g *ZeroGRPCV2) Warningf(format string, args ...interface{})
- func (g *ZeroGRPCV2) Warningln(args ...interface{})
Constants ¶
const ( GCPAlertLevel severityGCP = "ALERT" GCPCriticalLevel severityGCP = "CRITICAL" GCPErrorLevel severityGCP = "ERROR" GCPWarningLevel severityGCP = "WARNING" GCPInfoLevel severityGCP = "INFO" GCPDebugLevel severityGCP = "DEBUG" GCPFieldKeySeverity = "severity" GCPFieldKeyMsg = "message" GCPFieldKeyTime = "time" )
const ( KeyUnknown contextKey = iota KeyRequestID )
Variables ¶
This section is empty.
Functions ¶
func DisableGRPCLog ¶ added in v0.2.0
func DisableGRPCLog()
DisableGRPCLog sets the grpclog V2 logger to the discard logger. This must be called before any grpc calls are made because this method is not mutex protected.
func GinLogger ¶ added in v0.2.0
func GinLogger(server string) gin.HandlerFunc
GinLogger returns a new Gin middleware that performs logging for our JSON APIs using zerolog rather than the default Gin logger which is a standard HTTP logger. NOTE: we previously used github.com/dn365/gin-zerolog but wanted more customization.
func ResetLogger ¶ added in v0.2.0
func ResetLogger()
Types ¶
type LevelDecoder ¶
LogLevelDecoder deserializes the log level from a config string.
func (*LevelDecoder) Decode ¶
func (ll *LevelDecoder) Decode(value string) error
Decode implements confire Decoder interface.
func (*LevelDecoder) Encode ¶
func (ll *LevelDecoder) Encode() (string, error)
Encode converts the loglevel into a string for use in YAML and JSON
func (LevelDecoder) MarshalJSON ¶
func (ll LevelDecoder) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
func (LevelDecoder) String ¶
func (ll LevelDecoder) String() string
func (*LevelDecoder) UnmarshalJSON ¶
func (ll *LevelDecoder) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler
type SeverityHook ¶
type SeverityHook struct{}
SeverityHook adds GCP severity levels to zerolog output log messages.
type ZeroGRPCV2 ¶ added in v0.2.0
type ZeroGRPCV2 struct{}
Implements the grpclog.LoggerV2 interface to pass logging calls to zerolog. To enable grpclog with zerolog (e.g. for grpc logging to GCP) then set this logger before any grpc calls are made:
grpclog.SetLoggerV2(&logger.ZeroGRPCV2{})
This logger should respect the zerolog global log level from grpclog calls.
func (*ZeroGRPCV2) Error ¶ added in v0.2.0
func (g *ZeroGRPCV2) Error(args ...interface{})
Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.
func (*ZeroGRPCV2) Errorf ¶ added in v0.2.0
func (g *ZeroGRPCV2) Errorf(format string, args ...interface{})
Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
func (*ZeroGRPCV2) Errorln ¶ added in v0.2.0
func (g *ZeroGRPCV2) Errorln(args ...interface{})
Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
func (*ZeroGRPCV2) Fatal ¶ added in v0.2.0
func (g *ZeroGRPCV2) Fatal(args ...interface{})
Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*ZeroGRPCV2) Fatalf ¶ added in v0.2.0
func (g *ZeroGRPCV2) Fatalf(format string, args ...interface{})
Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*ZeroGRPCV2) Fatalln ¶ added in v0.2.0
func (g *ZeroGRPCV2) Fatalln(args ...interface{})
Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*ZeroGRPCV2) Info ¶ added in v0.2.0
func (g *ZeroGRPCV2) Info(args ...interface{})
Info logs to INFO log. Arguments are handled in the manner of fmt.Print.
func (*ZeroGRPCV2) Infof ¶ added in v0.2.0
func (g *ZeroGRPCV2) Infof(format string, args ...interface{})
Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf.
func (*ZeroGRPCV2) Infoln ¶ added in v0.2.0
func (g *ZeroGRPCV2) Infoln(args ...interface{})
Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.
func (*ZeroGRPCV2) V ¶ added in v0.2.0
func (g *ZeroGRPCV2) V(l int) bool
V reports whether verbosity level l is at least the requested verbose level.
func (*ZeroGRPCV2) Warning ¶ added in v0.2.0
func (g *ZeroGRPCV2) Warning(args ...interface{})
Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.
func (*ZeroGRPCV2) Warningf ¶ added in v0.2.0
func (g *ZeroGRPCV2) Warningf(format string, args ...interface{})
Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.
func (*ZeroGRPCV2) Warningln ¶ added in v0.2.0
func (g *ZeroGRPCV2) Warningln(args ...interface{})
Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.