log

package
v1.3.11 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: Apache-2.0 Imports: 9 Imported by: 60

Documentation

Index

Constants

View Source
const (
	LevelTrace = Level(1 << 6)
	LevelDebug = Level(1 << 5)
	LevelInfo  = Level(1 << 4)
	LevelWarn  = Level(1 << 3)
	LevelError = Level(1 << 2)
	LevelFatal = Level(1 << 1)
	LevelAll   = Level(0)
)
View Source
const (
	LF = "\n"
)

Variables

This section is empty.

Functions

func Debug added in v1.1.0

func Debug(s string) int

Debug outputs debug level message to loggers.

func Debugf added in v1.3.0

func Debugf(format string, args ...any) int

Debugf outputs a debug level message to loggers.

func EnableStdoutDebug added in v1.3.11

func EnableStdoutDebug(flag bool)

EnableStdoutDebug sets a trace stdout logger for debug.

func EnableStdoutTrace added in v1.3.11

func EnableStdoutTrace(flag bool)

EnableStdoutTrace sets a trace stdout logger for trace.

func Error

func Error(err error) int

Error outputs a error level message to loggers.

func Errorf added in v1.3.0

func Errorf(format string, args ...any) int

Errorf outputs a error level message to loggers.

func Fatal

func Fatal(s string) int

Fatal outputs a fatal level message to loggers.

func Fatalf added in v1.3.0

func Fatalf(format string, args ...any) int

Fatalf outputs a fatal level message to loggers.

func GetLevelString added in v1.3.4

func GetLevelString(logLevel Level) string

GetLevelString returns a string of the specified log level.

func HexDebug added in v1.2.0

func HexDebug(bytes []byte) int

Debug outputs a debug level message to loggers.

func HexError added in v1.2.0

func HexError(bytes []byte) int

Error outputs a error level message to loggers.

func HexFatal added in v1.2.0

func HexFatal(bytes []byte) int

Fatal outputs a fatal level message to loggers.

func HexInfo added in v1.2.0

func HexInfo(bytes []byte) int

Info outputs a information level message to loggers.

func HexOutput added in v1.2.0

func HexOutput(outputLevel Level, bytes []byte) int

Output outputs the specified level message to loggers.

func HexTrace added in v1.2.0

func HexTrace(bytes []byte) int

Trace outputs trace level message to loggers.

func HexWarn added in v1.2.0

func HexWarn(bytes []byte) int

Warn outputs a warning level message to loggers.

func Info

func Info(s string) int

Info outputs a information level message to loggers.

func Infof added in v1.3.0

func Infof(format string, args ...any) int

Infof outputs a information level message to loggers.

func Output

func Output(outputLevel Level, s string) int

Output outputs the specified level message to loggers.

func Outputf added in v1.3.0

func Outputf(outputLevel Level, format string, args ...any) int

Outputf outputs the specified level message to loggers.

func SetSharedLogger

func SetSharedLogger(logger *Logger)

SetSharedLogger sets a singleton logger.

func Trace

func Trace(s string) int

Trace outputs trace level message to loggers.

func Tracef added in v1.3.0

func Tracef(format string, args ...any) int

Tracef outputs trace level message to loggers.

func Warn

func Warn(s string) int

Warn outputs a warning level message to loggers.

func Warnf added in v1.3.0

func Warnf(format string, args ...any) int

Warnf outputs a warning level message to loggers.

Types

type Level

type Level int

Level represents a log level.

func GetLevelFromString added in v1.3.4

func GetLevelFromString(logLevel string) Level

GetLevelFromString returns a log level of the specified string.

type Logger

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

func GetSharedLogger

func GetSharedLogger() *Logger

GetSharedLogger gets a shared singleton logger.

func NewBufferLogger added in v1.3.5

func NewBufferLogger(buffer *bytes.Buffer, level Level) *Logger

NewBufferLogger creates a buffer logger.

func NewFileLogger

func NewFileLogger(file string, level Level) *Logger

NewFileLogger creates a file based logger.

func NewStdoutLogger

func NewStdoutLogger(level Level) *Logger

NewStdoutLogger creates a stdout logger.

func (*Logger) IsLevel added in v1.1.0

func (logger *Logger) IsLevel(logLevel Level) bool

IsLevel returns true when the specified log level is enable, otherwise false.

func (*Logger) Level

func (logger *Logger) Level() Level

Level gets the current log level.

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level Level)

SetLevel sets a output log level.

type LoggerOutpter

type LoggerOutpter func(logger *Logger, level Level, msg string) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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