logger

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 16 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 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. NOTE: we previously used github.com/dn365/gin-zerolog but wanted more customization.

func RequestID

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

func ResetLogger

func ResetLogger()

func Testing

func Testing(tb testing.TB)

func Tracing

func Tracing(ctx context.Context) zerolog.Logger

func WithRequestID

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.

Jump to

Keyboard shortcuts

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