kiko_logger

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = iota + 1
	// InfoLevel is the default logging priority.
	// General operational entries about what's going on inside the application.
	InfoLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	ErrorLevel
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. highest level of severity.
	FatalLevel
)

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, l Logger) context.Context

Types

type Level

type Level int8

type LogWriter

type LogWriter struct {
	LogFunc func() func(msg string, fields ...interface{})
}

func (LogWriter) Write

func (l LogWriter) Write(p []byte) (int, error)

type Logger

type Logger interface {

	// SetLevel set logger level
	SetLevel(lv Level)

	// WithContext with context
	WithContext(ctx context.Context) Logger

	// WithFields set fields to always be logged
	WithFields(fields map[string]interface{}) Logger

	// WithCallDepth  with logger call depth.
	WithCallDepth(callDepth int) Logger

	// WithError with logger error
	WithError(err error) Logger

	// Debug uses fmt.Sprint to construct and log a message.
	Debug(args ...interface{})

	// Info uses fmt.Sprint to construct and log a message.
	Info(args ...interface{})

	// Warn uses fmt.Sprint to construct and log a message.
	Warn(args ...interface{})

	// Error uses fmt.Sprint to construct and log a message.
	Error(args ...interface{})

	// Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
	Fatal(args ...interface{})

	// Debugf uses fmt.Sprintf to log a templated message.
	Debugf(template string, args ...interface{})

	// Infof uses fmt.Sprintf to log a templated message.
	Infof(template string, args ...interface{})

	// Warnf uses fmt.Sprintf to log a templated message.
	Warnf(template string, args ...interface{})

	// Errorf uses fmt.Sprintf to log a templated message.
	Errorf(template string, args ...interface{})

	// Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
	Fatalf(template string, args ...interface{})

	StdLog() *log.Logger

	// Sync logger sync
	Sync() error
}

func FromContext

func FromContext(ctx context.Context) (Logger, bool)

Jump to

Keyboard shortcuts

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