log

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevel = golog.DebugLevel
	InfoLevel  = golog.InfoLevel
	WarnLevel  = golog.WarnLevel
	ErrorLevel = golog.ErrorLevel
	FatalLevel = golog.FatalLevel
	PanicLevel = golog.FatalLevel
	TraceLevel = golog.DebugLevel
)
View Source
const IGNOREFLAG = `[IGNORE]`

Variables

View Source
var (
	Trace  = Debug
	Tracef = Debugf
)

Trace is named after Debug

View Source
var DefaultLogger = GetLogger("default")
View Source
var (
	ErrUnknowLevel = errors.New("unknown log level")
)
View Source
var (
	Level = os.Getenv("LOG_LEVEL")
)

Functions

func CheckLogDir

func CheckLogDir(dir string) error

func Debug

func Debug(v ...interface{})

Debug will print when logger's Level is debug.

func Debugf

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

Debugf will print when logger's Level is debug.

func Error

func Error(v ...interface{})

Error will print only when logger's Level is error, warn, info or debug.

func Errorf

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

Errorf will print only when logger's Level is error, warn, info or debug.

func Fatal

func Fatal(v ...interface{})

Fatal `os.Exit(1)` exit no matter the level of the logger. If the logger's level is fatal, error, warn, info or debug then it will print the log message too.

func Fatalf

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

Fatalf will `os.Exit(1)` no matter the level of the logger. If the logger's level is fatal, error, warn, info or debug then it will print the log message too.

func GetLevel

func GetLevel() golog.Level

func Info

func Info(v ...interface{})

Info will print when logger's Level is info or debug.

func Infof

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

Infof will print when logger's Level is info or debug.

func InitFileRotateLogger

func InitFileRotateLogger(baseLogPath string, logSaveDay int, logRotateHour int) error

func OnceInfoLog added in v1.3.2

func OnceInfoLog(key string, fmtStr string, args ...interface{})

func ParseLevel

func ParseLevel(raw string) (golog.Level, error)

func Print

func Print(v ...interface{})

Print prints a log message without levels and colors.

func Printf

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

Printf formats according to a format specifier and writes to `Printer#Output` without levels and colors.

func Println

func Println(v ...interface{})

Println prints a log message without levels and colors. It adds a new line at the end, it overrides the `NewLine` option.

func ReloadLogLevel

func ReloadLogLevel(c *Config)

func SetConfig

func SetConfig(c *Config)

func SetLevel

func SetLevel(level golog.Level)

func SetLoggerConfig

func SetLoggerConfig(l *Logger, c *Config)

func SetOutput

func SetOutput(w io.Writer)

func Warn

func Warn(v ...interface{})

Warn will print when logger's Level is warn, info or debug.

func Warnf

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

Warnf will print when logger's Level is warn, info or debug.

func Warningf

func Warningf(raw string, args ...interface{})

Types

type Config

type Config struct {
	Level      string
	FileConfig FileConfig `json:"file_config" yaml:"file_config"`
	Loggers    map[string]LoggerConfig
}

func GetConfig

func GetConfig() *Config

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) Clone

func (c *Config) Clone() *Config

type FileConfig

type FileConfig struct {
	Dir        string
	MaxSize    int // megabytes
	MaxBackUps int
	MaxAge     int // days
	Compress   bool
}

type Logger

type Logger struct {
	*golog.Logger
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger(name string) *Logger

GetLogger Return New Logger

func (*Logger) SetName added in v1.2.8

func (l *Logger) SetName(name string)

func (*Logger) SetVMRuntimeInfoGetter added in v1.2.8

func (l *Logger) SetVMRuntimeInfoGetter(f func(infoType string) (any, error))

type LoggerConfig

type LoggerConfig struct {
	Level string
}

Jump to

Keyboard shortcuts

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