Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultSize Default buffer size if any 默认缓冲区大小 DefaultSize = 256 // DefaultFormat Default formatter 默认格式化函数 DefaultFormat = TextFormat )
Functions ¶
func JSONFormat ¶
JSONFormat is a json format func JSONFormat 是 JSON 格式化函数
Types ¶
type FormatFunc ¶
FormatFunc is a function which formats the output FormatFunc 是格式化输出的函数
type Log ¶
type Log interface {
// Read reads log entries from the logger
// Read 从日志记录器中读取日志条目
Read(...ReadOption) ([]Record, error)
// Write writes records to log
// Write 将记录写入日志
Write(Record) error
// Stream log records
// Stream 日志记录流
Stream() (Stream, error)
}
Log is debug log interface for reading and writing logs Log 是用于读写日志的调试日志接口
type Options ¶
type Options struct {
// Name of the log
// 日志的名称
Name string
// Size is the size of ring buffer
// Size 是环形缓冲区的大小
Size int
// Format specifies the output format
// Format 指定输出格式
Format FormatFunc
}
Options are logger options Options 是日志记录器选项
type ReadOption ¶
type ReadOption func(*ReadOptions)
ReadOption used for reading the logs ReadOption 用于读取日志
func Count ¶
func Count(c int) ReadOption
Count sets the number of log records to return 设置要返回的日志记录数量
func Since ¶
func Since(s time.Time) ReadOption
Since sets the time since which to return the log records 设置从哪个时间点开始返回日志记录
type ReadOptions ¶
type ReadOptions struct {
// Since what time in past to return the logs
// 从过去的哪个时间点开始返回日志
Since time.Time
// Count specifies number of logs to return
// Count 指定要返回的日志数量
Count int
// Stream requests continuous log stream
// Stream 请求连续的日志流
Stream bool
}
ReadOptions for querying the logs ReadOptions 用于查询日志
type Record ¶
type Record struct {
// Timestamp of logged event
// 日志事件的时间戳
Timestamp time.Time `json:"timestamp"`
// Metadata to enrich log record
// 用于丰富日志记录的元数据
Metadata map[string]string `json:"metadata"`
// Value contains log entry
// 包含日志条目的值
Message interface{} `json:"message"`
}
Record is log record entry Record 是日志记录条目
Click to show internal directories.
Click to hide internal directories.