logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: BSD-3-Clause Imports: 15 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"
)
View Source
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 Discard added in v0.2.0

func Discard()

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 RequestID added in v0.2.0

func RequestID(ctx context.Context) (string, bool)

func ResetLogger added in v0.2.0

func ResetLogger()

func Testing added in v0.2.0

func Testing(tb testing.TB)

func Tracing added in v0.2.0

func Tracing(ctx context.Context) zerolog.Logger

func WithRequestID added in v0.2.0

func WithRequestID(parent context.Context, requestID string) context.Context

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

func (SeverityHook) Run

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

Run implements the zerolog.Hook interface.

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.

Jump to

Keyboard shortcuts

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