log

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level string

Level 日志级别类型

const (
	EMERGENCY Level = "emergency" // 系统无法使用,紧急情况
	ALERT     Level = "alert"     // 必须立即采取行动,例如:整个网站宕机、数据库挂起等,应发送短信或警报通知
	CRITICAL  Level = "critical"  // 临界条件,例如:应用组件不可用、严重异常
	ERROR     Level = "error"     // 运行时错误,不需要立即处理但通常应记录并监控
	WARNING   Level = "warning"   // 警告事件,非错误状态,例如:使用过时API、API使用不当等
	NOTICE    Level = "notice"    // 正常但重要的事件,值得关注的通知信息
	INFO      Level = "info"      // 一般信息性事件,例如:用户登录、SQL日志等
	DEBUG     Level = "debug"     // 详细的调试信息,用于开发和排错阶段
)

定义日志级别常量

type Logger

type Logger interface {
	contract.WithContext[Logger]
	// Emergency 输出紧急日志信息
	Emergency(content ...interface{})
	// Alert 输出警告日志信息,需要立即关注并采取行动
	Alert(content ...interface{})
	// Critical 输出临界条件日志信息
	Critical(content ...interface{})
	// Error 输出运行时错误日志信息
	Error(content ...interface{})
	// Warning 输出警告事件日志信息
	Warning(content ...interface{})
	// Notice 输出正常但重要的事件日志信息
	Notice(content ...interface{})
	// Info 输出一般信息事件日志
	Info(content ...interface{})
	// Debug 输出详细调试信息日志
	Debug(content ...interface{})
}

Logger 接口定义了不同日志级别的方法

type Options

type Options struct {
	Level      string `json:"level"`
	MaxSize    int    `json:"max-size"`
	MaxBackups int    `json:"max-backups"`
	MaxAge     int    `json:"max-age"`
	Compress   bool   `json:"compress"`
}

Source Files

  • logger.go

Jump to

Keyboard shortcuts

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