logger

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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"
)

Variables

This section is empty.

Functions

func DisableGRPCLog

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 Discard

func Discard()

func GinLogger

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. Provide the server name (e.g. adminAPI or BFF) to help us parse the logs. NOTE: we previously used github.com/dn365/gin-zerolog but wanted more customization.

func ResetLogger

func ResetLogger()

func Testing

func Testing(tb testing.TB)

Types

type LevelDecoder

type LevelDecoder zerolog.Level

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) MarshalYAML

func (ll LevelDecoder) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler

func (LevelDecoder) String

func (ll LevelDecoder) String() string

func (*LevelDecoder) UnmarshalJSON

func (ll *LevelDecoder) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (*LevelDecoder) UnmarshalYAML

func (ll *LevelDecoder) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler

type SeverityHook

type SeverityHook struct{}

SeverityHook adds GCP severity levels to zerolog output log messages.

func (SeverityHook) Run

func (h SeverityHook) Run(e *zerolog.Event, level zerolog.Level, msg string)

Run implements the zerolog.Hook interface.

type ZeroGRPCV2

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

func (g *ZeroGRPCV2) Error(args ...interface{})

Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.

func (*ZeroGRPCV2) Errorf

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

func (g *ZeroGRPCV2) Errorln(args ...interface{})

Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.

func (*ZeroGRPCV2) Fatal

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

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

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

func (g *ZeroGRPCV2) Info(args ...interface{})

Info logs to INFO log. Arguments are handled in the manner of fmt.Print.

func (*ZeroGRPCV2) Infof

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

func (g *ZeroGRPCV2) Infoln(args ...interface{})

Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.

func (*ZeroGRPCV2) V

func (g *ZeroGRPCV2) V(l int) bool

V reports whether verbosity level l is at least the requested verbose level.

func (*ZeroGRPCV2) Warning

func (g *ZeroGRPCV2) Warning(args ...interface{})

Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.

func (*ZeroGRPCV2) Warningf

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

func (g *ZeroGRPCV2) Warningln(args ...interface{})

Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL