logger

package
v0.0.0-...-cb65031 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields map[string]any

Fields denotes a logger field

type Level

type Level int8

Level denotes a logger level

const (
	// LevelTrace is a finer-grained log level
	LevelTrace Level = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelPanic
)

func (Level) String

func (l Level) String() string

String returns the string represent of log level

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger defines a logger struct

func NewLogger

func NewLogger(w io.Writer, prefix string, flag int) *Logger

NewLogger returns a logger instance with prefix and flag

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, v ...any)

Debug logs a message at Debug level

func (*Logger) Debugf

func (l *Logger) Debugf(ctx context.Context, format string, v ...any)

Debugf logs a message at Debug level

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, v ...any)

Error logs a message at Error level

func (*Logger) Errorf

func (l *Logger) Errorf(ctx context.Context, format string, v ...any)

Errorf logs a message at Error level

func (*Logger) Fatal

func (l *Logger) Fatal(ctx context.Context, v ...any)

Fatal logs a message at Fatal level

func (*Logger) Fatalf

func (l *Logger) Fatalf(ctx context.Context, format string, v ...any)

Fatalf logs a message at Fatal level

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, v ...any)

Info logs a message at Info level

func (*Logger) Infof

func (l *Logger) Infof(ctx context.Context, format string, v ...any)

Infof logs a message at Info level

func (*Logger) JSONFormat

func (l *Logger) JSONFormat(level Level, msg string) map[string]any

JSONFormat formats the given information into a log field

func (*Logger) Output

func (l *Logger) Output(level Level, msg string)

Output outputs corresponding message of log level

func (*Logger) Panic

func (l *Logger) Panic(ctx context.Context, v ...any)

Panic logs a message at Panic level

func (*Logger) Panicf

func (l *Logger) Panicf(ctx context.Context, format string, v ...any)

Panicf logs a message at Panic level

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, v ...any)

Trace logs a message at Trace level

func (*Logger) Tracef

func (l *Logger) Tracef(ctx context.Context, format string, v ...any)

Tracef logs a message at Trace level

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, v ...any)

Warn logs a message at Warn level

func (*Logger) Warnf

func (l *Logger) Warnf(ctx context.Context, format string, v ...any)

Warnf logs a message at Warn level

func (*Logger) WithCaller

func (l *Logger) WithCaller(depth int) *Logger

WithCaller returns a logger with caller, but caller message only for one line

func (*Logger) WithCallersFrames

func (l *Logger) WithCallersFrames() *Logger

WithCallersFrames returns a logger with whole callstack message

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) *Logger

WithContext returns a logger with context

func (*Logger) WithFields

func (l *Logger) WithFields(f Fields) *Logger

WithFields returns a logger with fields

func (*Logger) WithTrace

func (l *Logger) WithTrace() *Logger

WithTrace returns a logger with trace_id and span_id

Jump to

Keyboard shortcuts

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