log

package
v2.4.7 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelNone  = internal.LevelNone
	LevelDebug = internal.LevelDebug
	LevelInfo  = internal.LevelInfo
	LevelWarn  = internal.LevelWarn
	LevelError = internal.LevelError
	LevelFatal = internal.LevelFatal
	LevelPanic = internal.LevelPanic
)

Variables

This section is empty.

Functions

func Close

func Close()

Close 关闭日志

func Debug

func Debug(a ...any)

Debug 打印调试日志

func Debugf

func Debugf(format string, a ...any)

Debugf 打印调试模板日志

func Error

func Error(a ...any)

Error 打印错误日志

func Errorf

func Errorf(format string, a ...any)

Errorf 打印错误模板日志

func Fatal

func Fatal(a ...any)

Fatal 打印致命错误日志

func Fatalf

func Fatalf(format string, a ...any)

Fatalf 打印致命错误模板日志

func Info

func Info(a ...any)

Info 打印信息日志

func Infof

func Infof(format string, a ...any)

Infof 打印信息模板日志

func NewLogger

func NewLogger(opts ...Option) *defaultLogger

func Panic

func Panic(a ...any)

Panic 打印Panic日志

func Panicf

func Panicf(format string, a ...any)

Panicf 打印Panic模板日志

func Print

func Print(level Level, a ...any)

Print 打印日志,不含堆栈信息

func Printf

func Printf(level Level, format string, a ...any)

Printf 打印模板日志,不含堆栈信息

func SetLogger

func SetLogger(logger Logger)

SetLogger 设置日志记录器

func Warn

func Warn(a ...any)

Warn 打印警告日志

func Warnf

func Warnf(format string, a ...any)

Warnf 打印警告模板日志

Types

type Entity

type Entity = internal.Entity

type Level

type Level = internal.Level

type Logger

type Logger interface {
	// Print 打印日志,不含堆栈信息
	Print(level Level, a ...any)
	// Printf 打印模板日志,不含堆栈信息
	Printf(level Level, format string, a ...any)
	// Debug 打印调试日志
	Debug(a ...any)
	// Debugf 打印调试模板日志
	Debugf(format string, a ...any)
	// Info 打印信息日志
	Info(a ...any)
	// Infof 打印信息模板日志
	Infof(format string, a ...any)
	// Warn 打印警告日志
	Warn(a ...any)
	// Warnf 打印警告模板日志
	Warnf(format string, a ...any)
	// Error 打印错误日志
	Error(a ...any)
	// Errorf 打印错误模板日志
	Errorf(format string, a ...any)
	// Fatal 打印致命错误日志
	Fatal(a ...any)
	// Fatalf 打印致命错误模板日志
	Fatalf(format string, a ...any)
	// Panic 打印Panic日志
	Panic(a ...any)
	// Panicf 打印Panic模板日志
	Panicf(format string, a ...any)
	// Close 关闭日志
	Close() error
}

func GetLogger

func GetLogger() Logger

GetLogger 获取日志记录器

type Option

type Option func(o *options)

func WithCallFullPath

func WithCallFullPath(fullPath bool) Option

WithCallFullPath 设置日志的输出栈的调用文件全路径

func WithCallSkip

func WithCallSkip(skip int) Option

WithCallSkip 设置输出栈的跳过深度

func WithLevel

func WithLevel(level Level) Option

WithLevel 设置日志的输出级别

func WithStackLevel

func WithStackLevel(level Level) Option

WithStackLevel 设置日志的输出栈的日志级别

func WithSyncers

func WithSyncers(syncers ...Syncer) Option

WithSyncers 设置日志同步器

func WithTerminals

func WithTerminals[T Terminal | []Terminal | map[Terminal][]Level](terminals ...T) Option

WithTerminals 设置日志的输出终端

func WithTimeFormat

func WithTimeFormat(timeFormat string) Option

WithTimeFormat 设置日志输出时间格式

type Syncer

type Syncer = internal.Syncer

type Terminal

type Terminal string

Terminal 日志输出终端

const (
	TerminalConsole Terminal = "console" // 控制台
	TerminalFile    Terminal = "file"    // 文件
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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