log

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 54

Documentation

Index

Constants

View Source
const (
	LevelDebug = Level(1 << 6)
	LevelTrace = 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 Debugf added in v1.3.0

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

Debugf outputs a debug level message to loggers.

func DecodeHexLog added in v1.3.5

func DecodeHexLog(logs []string) ([]byte, error)

DecodeHexLog decodes the specified hex log.

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 ...interface{}) int

Errorf outputs a error level message to loggers.

func Fatalf added in v1.3.0

func Fatalf(format string, args ...interface{}) 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 Infof added in v1.3.0

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

Infof outputs a information level message to loggers.

func Outputf added in v1.3.0

func Outputf(outputLevel Level, format string, args ...interface{}) int

Outputf outputs the specified level message to loggers.

func SetSharedLogger

func SetSharedLogger(logger *Logger)

SetSharedLogger sets a singleton logger.

func SetStdoutDebugEnbled

func SetStdoutDebugEnbled(flag bool)

SetStdoutDebugEnbled sets a trace stdout logger for debug.

func Tracef added in v1.3.0

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

Tracef outputs trace level message to loggers.

func Warnf added in v1.3.0

func Warnf(format string, args ...interface{}) 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