logging

package
v0.0.0-...-7d047eb Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: AGPL-3.0 Imports: 4 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug uses fmt.Sprint to construct and log a message at DebugLevel.

func Debugf

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

Debugf uses fmt.Sprintf to log a formatted message at DebugLevel.

func Error

func Error(args ...interface{})

Error uses fmt.Sprint to construct and log a message at ErrorLevel.

func Errorf

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

Errorf uses fmt.Sprintf log a formatted message at ErrorLevel.

func Fatal

func Fatal(args ...interface{})

Fatal uses fmt.Sprint to construct and log a message at FatalLevel, then calls os.Exit.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf uses fmt.Sprintf log a formatted message at FatalLevel, then calls os.Exit.

func Info

func Info(args ...interface{})

Info uses fmt.Sprint to construct and log a message at InfoLevel.

func Infof

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

Infof uses fmt.Sprintf log a formatted message at InfoLevel.

func Panic

func Panic(args ...interface{})

Panic uses fmt.Sprint to construct and log a message at PanicLevel, then panics.

func Panicf

func Panicf(template string, args ...interface{})

Panicf uses fmt.Sprintf log a formatted message at PanicLevel, then panics.

func Warn

func Warn(args ...interface{})

Warn uses fmt.Sprint to construct and log a message at WarnLevel.

func Warnf

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

Warnf uses fmt.Sprintf log a formatted message at WarnLevel.

Types

type Flags

type Flags int8

Type Flags represents logger flags (a wrapper around log.L* flags).

var (
	// More verbose logging flags for debugging/development.
	FlagsDevelopment Flags = log.LstdFlags | log.Lmicroseconds | log.Lmsgprefix
	// Less verbose logging info.
	FlagsProduction Flags = log.LstdFlags | log.Lmsgprefix
)

type Level

type Level int8

A Level is a logging priority. Higher levels are more important.

const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = iota - 1
	// InfoLevel is the default logging priority.
	InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

func (Level) String

func (l Level) String() string

String returns a lower-case ASCII representation of the log level.

type Logger

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

Type Logger represents a logger instance with a specific unit name (prefix) and logging level. New instances are to be created with logging.New().

func New

func New() *Logger

Creates a new Logger with the given options. The default logger has FlagsProduction, logs at InfoLevel, has no prefix and outputs to os.Stderr.

func (Logger) Debug

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

Debug uses fmt.Sprint to construct and log a message at DebugLevel.

func (Logger) Debugf

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

Debugf uses fmt.Sprintf to log a formatted message at DebugLevel.

func (Logger) Error

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

Error uses fmt.Sprint to construct and log a message at ErrorLevel.

func (Logger) Errorf

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

Errorf uses fmt.Sprintf log a formatted message at ErrorLevel.

func (Logger) Fatal

func (l Logger) Fatal(args ...interface{})

Fatal uses fmt.Sprint to construct and log a message at FatalLevel, then calls os.Exit.

func (Logger) Fatalf

func (l Logger) Fatalf(template string, args ...interface{})

Fatalf uses fmt.Sprintf log a formatted message at FatalLevel, then calls os.Exit.

func (Logger) Info

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

Info uses fmt.Sprint to construct and log a message at InfoLevel.

func (Logger) Infof

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

Infof uses fmt.Sprintf log a formatted message at InfoLevel.

func (Logger) Panic

func (l Logger) Panic(args ...interface{})

Panic uses fmt.Sprint to construct and log a message at PanicLevel, then panics.

func (Logger) Panicf

func (l Logger) Panicf(template string, args ...interface{})

Panicf uses fmt.Sprintf log a formatted message at PanicLevel, then panics.

func (Logger) Warn

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

Warn uses fmt.Sprint to construct and log a message at WarnLevel.

func (Logger) Warnf

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

Warnf uses fmt.Sprintf log a formatted message at WarnLevel.

func (*Logger) WithFlags

func (l *Logger) WithFlags(flags Flags) *Logger

Changes the flags for the inderlying log.Logger. Default is FlagsProduction.

func (*Logger) WithLevel

func (l *Logger) WithLevel(lvl Level) *Logger

Sets a minimum logging level for the logger being created. Default is InfoLevel.

func (*Logger) WithOutput

func (l *Logger) WithOutput(w io.Writer) *Logger

Sets the output sink for the underlying log.Logger.

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(prefix string) *Logger

Gives a specific name to the logger. Will be included in the output as '[prefix]'. Default is empty string (no prefix will be printed).

Jump to

Keyboard shortcuts

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