logger

package
v0.0.0-...-f36573f Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func For

func For(ctx context.Context) *logrus.Entry

func GinFormatter

func GinFormatter() gin.LogFormatter

GinFormatter returns a gin.LogFormatter that includes additional context via logrus

func InitWithGCPDefaults

func InitWithGCPDefaults()

InitWithGCPDefaults initializes a logger suitable for most Google Cloud Logging purposes

func NewContextWithFields

func NewContextWithFields(parent context.Context, fields logrus.Fields) context.Context

NewContextWithFields returns a new context with a log entry derived from the default logger.

func SetLoggerOptions

func SetLoggerOptions(optionsFunc func(logger *logrus.Logger))

Types

type GCPFormatter

type GCPFormatter struct {
	logrus.JSONFormatter
}

GCPFormatter is a logrus.JSONFormatter with additional handling to map log severity and timestamps to the specific named JSON fields ("severity" and "time") that Google Cloud Logging expects

func NewGCPFormatter

func NewGCPFormatter() *GCPFormatter

func (*GCPFormatter) Format

func (f *GCPFormatter) Format(entry *logrus.Entry) ([]byte, error)

type LoggedError

type LoggedError struct {
	Message string         // The original message passed to the logger
	Err     error          // The error added to the logger
	Caller  *runtime.Frame // Available if logger is configured to report on the caller
}

LoggedError wraps the original error and logging message.

func (LoggedError) Error

func (e LoggedError) Error() string

Jump to

Keyboard shortcuts

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