log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug   = log.Debug
	Debugf  = log.Debugf
	Error   = log.Error
	Errorf  = log.Errorf
	Fatal   = log.Fatal
	Fatalf  = log.Fatalf
	Info    = log.Info
	Infof   = log.Infof
	Print   = log.Print
	Printf  = log.Printf
	Println = log.Println
	Trace   = log.Trace
	Tracef  = log.Tracef
	Warn    = log.Warn
	Warnf   = log.Warnf

	WithContext = log.WithContext
	WithError   = log.WithError
	WithField   = log.WithField
	WithFields  = log.WithFields

	RegisterExitHandler = logrus.RegisterExitHandler
)

define aliases to logrus.

View Source
var (
	// JSONLogFormatter formats logs into parsable json.
	JSONLogFormatter = &logrus.JSONFormatter{TimestampFormat: "2006-01-02T15:04:05.000-07:00", CallerPrettyfier: callerPretty, DisableHTMLEscape: true}

	// TextLogFormatter formats logs into text.
	TextLogFormatter = &logrus.TextFormatter{TimestampFormat: "2006-01-02T15:04:05.000-07:00", FullTimestamp: true, CallerPrettyfier: callerPretty}
)

Functions

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled checks if the log level is greater than the debug level.

func Log

func Log() *logrus.Logger

Log returns the default logger.

func New

func New() *logrus.Logger

New creates a new logger.

func RequestIDContext

func RequestIDContext(ctx context.Context, id ...string) context.Context

RequestIDContext set request id to context. The requestIDHook will read it. If an empty id is passed in, a randomly one will be generated.

func SetFormatter

func SetFormatter(f string, pretty bool)

SetFormatter sets the standard logger formatter.

func SetLevel

func SetLevel(l string)

SetLevel sets the logger level.

func SetOutput

func SetOutput(o string)

SetOutput sets the logger output.

func Writer

func Writer(output string) io.Writer

Writer get an io.Writer according to the output.

Types

type Fields

type Fields = logrus.Fields

define type aliases to logrus.

type Logger

type Logger = logrus.Logger

define type aliases to logrus.

Jump to

Keyboard shortcuts

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