log

package
v2.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug calls the default logger's Debug method.

func Debugf

func Debugf(format string, v ...interface{})

Debugf calls the default logger's Debugf method.

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

func Error

func Error(v ...interface{})

Error calls the default logger's Error method.

func Errorf

func Errorf(format string, v ...interface{})

Errorf calls the default logger's Errorf method.

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

func Fatal

func Fatal(v ...interface{})

Fatal calls the default logger's Fatal method and then os.Exit(1).

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf calls the default logger's Fatalf method and then os.Exit(1).

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

Fatalw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

func Info

func Info(v ...interface{})

Info calls the default logger's Info method.

func Infof

func Infof(format string, v ...interface{})

Infof calls the default logger's Infof method.

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

func Panic

func Panic(v ...interface{})

Panic calls the default logger's Panic method.

func Panicf

func Panicf(format string, v ...interface{})

Panicf calls the default logger's Tracef method.

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

Panicw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

func SetLevel

func SetLevel(lv Level)

SetLevel sets the level of logs below which logs will not be output. The default logger is LevelTrace. Note that this method is not concurrent-safe.

func SetLogger

func SetLogger(v AllLogger)

SetLogger sets the default logger and the system logger. Note that this method is not concurrent-safe and must not be called after the use of DefaultLogger and global functions privateLog this package.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output of default logger and system logger. By default, it is stderr.

func Trace

func Trace(v ...interface{})

Trace calls the default logger's Trace method.

func Tracef

func Tracef(format string, v ...interface{})

Tracef calls the default logger's Tracef method.

func Tracew

func Tracew(msg string, keysAndValues ...interface{})

Tracew logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

func Warn

func Warn(v ...interface{})

Warn calls the default logger's Warn method.

func Warnf

func Warnf(format string, v ...interface{})

Warnf calls the default logger's Warnf method.

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.

Types

type AllLogger

type AllLogger interface {
	CommonLogger
	ControlLogger
	WithContext(ctx context.Context) CommonLogger
}

AllLogger is the combination of Logger, FormatLogger, CtxLogger and ControlLogger. Custom extensions can be made through AllLogger

func DefaultLogger

func DefaultLogger() AllLogger

DefaultLogger returns the default logger.

type CommonLogger

type CommonLogger interface {
	Logger
	FormatLogger
	WithLogger
}

func WithContext

func WithContext(ctx context.Context) CommonLogger

type ControlLogger

type ControlLogger interface {
	SetLevel(Level)
	SetOutput(io.Writer)
}

ControlLogger provides methods to config a logger.

type FormatLogger

type FormatLogger interface {
	Tracef(format string, v ...interface{})
	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Fatalf(format string, v ...interface{})
	Panicf(format string, v ...interface{})
}

FormatLogger is a logger interface that output logs with a format.

type Level

type Level int

Level defines the priority of a log message. When a logger is configured with a level, any log message with a lower log level (smaller by integer comparison) will not be output.

const (
	LevelTrace Level = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelPanic
)

The levels of logs.

type Logger

type Logger interface {
	Trace(v ...interface{})
	Debug(v ...interface{})
	Info(v ...interface{})
	Warn(v ...interface{})
	Error(v ...interface{})
	Fatal(v ...interface{})
	Panic(v ...interface{})
}

Logger is a logger interface that provides logging function with levels.

type WithLogger

type WithLogger interface {
	Tracew(msg string, keysAndValues ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
}

WithLogger is a logger interface that output logs with a message and key-value pairs.

Jump to

Keyboard shortcuts

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