Documentation ¶
Overview ¶
Package vlog (Virtual Logger) 是一组抽象的日志接口,为程序提供统一的日志调用方式。
Index ¶
- Constants
- func LockDefaultFactory()
- func SetDefaultFactory(f LoggerFactory)
- func UseSimpleLogger(enableLevel Level)
- type Channel
- type DefaultLoggerFactory
- type Filter
- type FilterChain
- type Formatter
- type Level
- type Logger
- type LoggerAdapter
- func (inst *LoggerAdapter) Debug(a ...interface{}) Logger
- func (inst *LoggerAdapter) Error(a ...interface{}) Logger
- func (inst *LoggerAdapter) Fatal(a ...interface{}) Logger
- func (inst *LoggerAdapter) Info(a ...interface{}) Logger
- func (inst *LoggerAdapter) IsDebugEnabled() bool
- func (inst *LoggerAdapter) IsErrorEnabled() bool
- func (inst *LoggerAdapter) IsFatalEnabled() bool
- func (inst *LoggerAdapter) IsInfoEnabled() bool
- func (inst *LoggerAdapter) IsTraceEnabled() bool
- func (inst *LoggerAdapter) IsWarnEnabled() bool
- func (inst *LoggerAdapter) Trace(a ...interface{}) Logger
- func (inst *LoggerAdapter) Warn(a ...interface{}) Logger
- type LoggerFactory
- type Record
- type SimpleFormatter
- type SimpleLoggerFactory
- type Writer
Constants ¶
View Source
const ( // ALL 启用所有信息 ALL = 1 // TRACE 跟踪信息 TRACE = 2 // DEBUG 调试信息 DEBUG = 3 // INFO 常规信息 INFO = 4 // WARN 警告信息 WARN = 5 // ERROR 错误信息 ERROR = 6 // FATAL 致命错误信息 FATAL = 7 // NONE 禁用所有信息 NONE = 8 )
View Source
const ( FormatStyleFatal = "\033[97;40m" FormatStyleError = "\033[97;41m" FormatStyleWarn = "\033[30;103m" FormatStyleInfo = "\033[0m" FormatStyleDebug = "\033[97;42m" FormatStyleTrace = "\033[97;46m" FormatStyleNormal = "\033[0m" )
Variables ¶
This section is empty.
Functions ¶
func LockDefaultFactory ¶ added in v0.0.41
func LockDefaultFactory()
LockDefaultFactory 锁定当前的默认 Logger 工厂
func SetDefaultFactory ¶ added in v0.0.41
func SetDefaultFactory(f LoggerFactory)
SetDefaultFactory 设置默认 Logger 工厂
func UseSimpleLogger ¶ added in v0.0.41
func UseSimpleLogger(enableLevel Level)
UseSimpleLogger 设置日志系统使用简单的logger工厂
Types ¶
type DefaultLoggerFactory ¶
type DefaultLoggerFactory struct {
// contains filtered or unexported fields
}
func (*DefaultLoggerFactory) CreateLogger ¶
func (inst *DefaultLoggerFactory) CreateLogger(src interface{}) Logger
type Filter ¶
type Filter interface { // DoFilter 方法过滤一条记录 DoFilter(rec *Record, chain FilterChain) }
Filter 是日志记录的过滤器
type FilterChain ¶
type FilterChain interface { // Append 方法向链条追加一条记录 Append(rec *Record) }
FilterChain 是过滤器的链条
type Logger ¶
type Logger interface { Fatal(a ...interface{}) Logger Error(a ...interface{}) Logger Warn(a ...interface{}) Logger Info(a ...interface{}) Logger Debug(a ...interface{}) Logger Trace(a ...interface{}) Logger IsFatalEnabled() bool IsErrorEnabled() bool IsWarnEnabled() bool IsInfoEnabled() bool IsDebugEnabled() bool IsTraceEnabled() bool }
Logger 是一个统一的抽象日志接口
type LoggerAdapter ¶
type LoggerAdapter struct { // public LoggerFactory LoggerFactory // contains filtered or unexported fields }
func (*LoggerAdapter) Debug ¶
func (inst *LoggerAdapter) Debug(a ...interface{}) Logger
func (*LoggerAdapter) Error ¶
func (inst *LoggerAdapter) Error(a ...interface{}) Logger
func (*LoggerAdapter) Fatal ¶
func (inst *LoggerAdapter) Fatal(a ...interface{}) Logger
func (*LoggerAdapter) Info ¶
func (inst *LoggerAdapter) Info(a ...interface{}) Logger
func (*LoggerAdapter) IsDebugEnabled ¶
func (inst *LoggerAdapter) IsDebugEnabled() bool
func (*LoggerAdapter) IsErrorEnabled ¶
func (inst *LoggerAdapter) IsErrorEnabled() bool
func (*LoggerAdapter) IsFatalEnabled ¶
func (inst *LoggerAdapter) IsFatalEnabled() bool
func (*LoggerAdapter) IsInfoEnabled ¶
func (inst *LoggerAdapter) IsInfoEnabled() bool
func (*LoggerAdapter) IsTraceEnabled ¶
func (inst *LoggerAdapter) IsTraceEnabled() bool
func (*LoggerAdapter) IsWarnEnabled ¶
func (inst *LoggerAdapter) IsWarnEnabled() bool
func (*LoggerAdapter) Trace ¶
func (inst *LoggerAdapter) Trace(a ...interface{}) Logger
func (*LoggerAdapter) Warn ¶
func (inst *LoggerAdapter) Warn(a ...interface{}) Logger
type LoggerFactory ¶
type LoggerFactory interface { // CreateLogger 新建Logger CreateLogger(source interface{}) Logger }
LoggerFactory 是Logger的工厂
func NewSimpleLoggerFactory ¶ added in v0.0.41
func NewSimpleLoggerFactory(enableLevel Level) LoggerFactory
NewSimpleLoggerFactory 新建一个显示指定级别日志信息的简单logger工厂
type Record ¶
type Record struct { // 时间戳 Timestamp int64 // 记录等级 Level Level // 参数 Arguments []interface{} // Source 表示本条记录的来源 Source interface{} // Message 是由 Formatter 生成的字符串 Message string }
Record 表示一条日志记录
type SimpleFormatter ¶ added in v0.0.56
type SimpleFormatter struct { }
func (*SimpleFormatter) Format ¶ added in v0.0.56
func (inst *SimpleFormatter) Format(r *Record) string
type SimpleLoggerFactory ¶
type SimpleLoggerFactory struct {
// contains filtered or unexported fields
}
SimpleLoggerFactory 是一个简单的日志工厂
func (*SimpleLoggerFactory) CreateLogger ¶
func (inst *SimpleLoggerFactory) CreateLogger(source interface{}) Logger
Source Files ¶
Click to show internal directories.
Click to hide internal directories.