logging

package module
v0.0.0-...-88b424d Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: AGPL-3.0 Imports: 11 Imported by: 41

README

Logging

Logging for SiYuan.

Documentation

Index

Constants

View Source
const (
	ExitCodeUnavailableDatabase = 20 // 不可用的数据库
	ExitCodeUnavailablePort     = 21 // 不可用的端口
	ExitCodeSecurityRisk        = 22 // 存在安全风险
	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 LogDebug

func LogDebug(content string)

func LogDebugf

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

func LogError

func LogError(content string)

func LogErrorf

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

func LogFatal

func LogFatal(exitCode int, content string)

func LogFatalf

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

func LogInfo

func LogInfo(content string)

func LogInfof

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

func LogTrace

func LogTrace(content string)

func LogTracef

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

func LogWarn

func LogWarn(content string)

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