logger

package
v2.4.9 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(errorCode int, args ...interface{})

func Fatalf

func Fatalf(errorCode int, format string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

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

func Output added in v2.3.9

func Output(level LogLevel) io.Writer

func PWriter

func PWriter(label string, level LogLevel) io.Writer

func SetLevel

func SetLevel(level LogLevel)

func SetOutput added in v2.3.9

func SetOutput(level LogLevel, w io.Writer)

func Setup

func Setup(l *Logger)

func Warn

func Warn(args ...interface{})

func Warnf

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

func Writer

func Writer(level LogLevel) io.Writer

Types

type LogLevel

type LogLevel int8
const (

	// DebugLevel is the lowest log level.
	DebugLevel LogLevel = iota

	// InfoLevel is the default log level.
	InfoLevel

	// WarnLevel is used for warnings.
	WarnLevel

	// ErrorLevel is used for errors.
	ErrorLevel

	// OutputAll is used to output all log levels in the SetOutput function.
	OutputAll LogLevel = -1
)

func (LogLevel) String

func (l LogLevel) String() string

type LogWriter

type LogWriter struct {
	Logger *Logger
	Level  LogLevel
	// contains filtered or unexported fields
}

func (*LogWriter) Write

func (lw *LogWriter) Write(p []byte) (n int, err error)

type Logger

type Logger struct {
	// Level is the log level.
	Level LogLevel

	// Prefix is the prefix for each log message.
	Prefix string

	// Suffix is the suffix for each log message.
	Suffix string

	// Display a timestamp alongside the log message.
	OutputTime bool

	// Outputs for the log messages.
	OutputDebug io.Writer
	OutputInfo  io.Writer
	OutputWarn  io.Writer
	OutputError io.Writer

	// WrapPrefix determines how the prefix should be wrapped
	// based on the LogLevel.
	WrapPrefix func(LogLevel, string) string
}

func Global

func Global() *Logger

func (*Logger) Copy

func (l *Logger) Copy() *Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(errorcode int, args ...interface{})

Fatal is a convenience function for logging an error and exiting the program.

func (*Logger) Fatalf

func (l *Logger) Fatalf(errorcode int, format string, args ...interface{})

Fatalf is a convenience function for logging an error and exiting the program.

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) Log

func (l *Logger) Log(level LogLevel, args ...interface{})

func (*Logger) Output

func (l *Logger) Output(level LogLevel) io.Writer

func (*Logger) PWriter

func (l *Logger) PWriter(label string, level LogLevel) io.Writer

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

func (*Logger) SetOutput added in v2.3.9

func (l *Logger) SetOutput(level LogLevel, w io.Writer)

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

func (*Logger) Writer

func (l *Logger) Writer(level LogLevel) io.Writer

Jump to

Keyboard shortcuts

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