logging

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: AGPL-3.0 Imports: 11 Imported by: 5

README

Logging

Logging for Sillot.

Documentation

Index

Constants

View Source
const (
	ExitCodeReadOnlyDatabase = 20 // 数据库文件被锁
	ExitCodeUnavailablePort  = 21 // 端口不可用
	ExitCodeWorkspaceLocked  = 24 // 工作空间已被锁定
	ExitCodeInitWorkspaceErr = 25 // 初始化工作空间失败
	ExitCodeFileSysErr       = 26 // 文件系统错误
	ExitCodeOk               = 0  // 正常退出
	ExitCodeFatal            = 1  // 致命错误
)
View Source
const (
	Off = iota
	Trace
	Debug
	Info
	Warn
	Error
	Fatal
)

Logging level.

Variables

View Source
var (
	LogPath string
)

Functions

func LogDebugf

func LogDebugf(format string, v ...interface{})

func LogErrorf

func LogErrorf(format string, v ...interface{})

func LogFatalf

func LogFatalf(exitCode int, format string, v ...interface{})

func LogInfof

func LogInfof(format string, v ...interface{})

func LogTracef

func LogTracef(format string, v ...interface{})

func LogWarnf

func LogWarnf(format string, v ...interface{})

func Recover

func Recover()

func SetLogLevel

func SetLogLevel(level string)

SetLogLevel sets the logging level of all loggers.

func SetLogPath

func SetLogPath(path string)

func ShortStack

func ShortStack() string

Types

type Logger

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

Logger represents a simple logger with level. The underlying logger is the standard Go logging "log".

func NewLogger

func NewLogger(out io.Writer) *Logger

NewLogger creates a logger.

func (*Logger) Debugf

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

Debugf prints debug level message with format.

func (*Logger) Errorf

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

Errorf prints error level message with format.

func (*Logger) Fatalf

func (l *Logger) Fatalf(exitCode int, format string, v ...interface{})

Fatalf prints fatal level message with format and exit process with code 1.

func (*Logger) Infof

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

Infof prints info level message with format.

func (*Logger) IsDebugEnabled

func (l *Logger) IsDebugEnabled() bool

IsDebugEnabled determines whether the debug level is enabled.

func (*Logger) IsTraceEnabled

func (l *Logger) IsTraceEnabled() bool

IsTraceEnabled determines whether the trace level is enabled.

func (*Logger) IsWarnEnabled

func (l *Logger) IsWarnEnabled() bool

IsWarnEnabled determines whether the debug level is enabled.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string)

SetLevel sets the logging level of a logger.

func (*Logger) Tracef

func (l *Logger) Tracef(format string, v ...interface{})

Tracef prints trace level message with format.

func (*Logger) Warnf

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

Warnf prints warning level message with format.

Jump to

Keyboard shortcuts

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