Documentation ¶
Index ¶
- Variables
- func SetLogger(l PsLogger)
- type FileInfo
- type Handler
- type LogDir
- type LogHandlerBus
- type LogPath
- type Matcher
- type Opt
- type Project
- type ProjectLog
- type ProjectSrc
- type PsLog
- func (p *PsLog) AddPath2Handler(path string, handler *Handler) error
- func (p *PsLog) AddPath2HandlerMap(path2HandlerMap map[string]*Handler) error
- func (p *PsLog) AddPaths(paths ...string) error
- func (p *PsLog) Close()
- func (p *PsLog) CronLogs()
- func (p *PsLog) HasClose() bool
- func (p *PsLog) List() string
- func (p *PsLog) Register(handler *Handler) error
- func (p *PsLog) TailLogs(watchChSize ...int) error
- type PsLogWriter
- type PsLogger
- type Simple
- type Stdout
- type Target
- type Tire
- type Watch
- type WatchFileInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var (
NoExpire = base.Datetime2TimeObj("9999-12-31 23:59:59") // 不过期
)
Functions ¶
Types ¶
type FileInfo ¶
type FileInfo struct { Handler *Handler // 这里优先 PsLog.handler Dir string // 文件目录 Name string // 文件名 // contains filtered or unexported fields }
func (*FileInfo) CleanNameFmt ¶
CleanNameFmt 清理 Name 中的格式, 如: test.log => test
type Handler ¶
type Handler struct { CleanOffset bool // 是否需要清理保存的 offset Tail bool // 是否实时处理, 说明: true 为实时; false 需要外部定时调用 Change int32 // 文件 offset 变化次数, 为持久化文件偏移量数阈值, 当, 说明: -1 为实时保存; 0 达到默认值 defaultHandleChange 时保存; 其他 大于后会保存 ExpireDur time.Duration // 文件句柄过期间隔, 常用于全局配置 ExpireAt time.Time // 文件句柄过期时间, 优先 ExpireDur 如: 2022-12-03 11:11:10 Targets []*Target // 目标 msg Ext string // 外部存入, 回调返回 // contains filtered or unexported fields }
Handler 处理的部分
type LogHandlerBus ¶ added in v1.0.0
type LogHandlerBus struct { LogPath string // log 的路径 Msg string // buf 中的 string Ext string // Handler 中的 Ext 值 // contains filtered or unexported fields }
logHandler 解析到的内容
func (*LogHandlerBus) Reset ¶ added in v1.0.0
func (l *LogHandlerBus) Reset()
func (*LogHandlerBus) Write ¶ added in v1.0.0
func (l *LogHandlerBus) Write(b []byte)
type LogPath ¶ added in v1.0.0
type LogPath struct {
// contains filtered or unexported fields
}
func NewLogPath ¶ added in v1.0.0
func NewLogPath() *LogPath
func (*LogPath) ParseLogPath ¶ added in v1.0.0
func (l *LogPath) ParseLogPath(project *Project) []*ProjectLog
ParseLogPaths 解析项目 log path
func (*LogPath) ParseSrc ¶ added in v1.0.0
func (l *LogPath) ParseSrc(src *ProjectSrc) []*ProjectLog
ParseSrc 收集 src 下的 go 项目, 注意: src.SrcPath 必须为绝对路径 src 目录即为项目根目录, 目录结构如下:
src ├── demo1 │ ├── app │ ├── boot │ ├── config │ ├── log │ ├── main.go └── demo2 │ ├── app │ ├── boot │ ├── config │ ├── log │ ├── main.go
func (*LogPath) SetExcludeProjectDir ¶ added in v1.0.0
SetExcludeProjectDir 设置排除的项目目录
type Project ¶ added in v1.0.0
type Project struct { LogDir *LogDir ProjectPath string // 项目 path, 必须为绝对路径, 如: /root/demo/src/demo }
Project 项目根目录
type ProjectLog ¶ added in v1.0.0
type ProjectSrc ¶ added in v1.0.0
ProjectSrc 项目根目录
type PsLog ¶
type PsLog struct {
// contains filtered or unexported fields
}
PsLog 解析 log
func (*PsLog) AddPath2Handler ¶ added in v1.0.0
AddPath2Handler 单个添加 会根据文件对应的 Handler 进行处理, 如果为 Handler 为 nil, 会按 p.handler 来处理
func (*PsLog) AddPath2HandlerMap ¶
AddPath2HandlerMap 添加文件对应的处理方法 会根据文件对应的 Handler 进行处理, 如果为 Handler 为 nil, 会按 p.handler 来处理
type PsLogWriter ¶ added in v1.0.0
type PsLogWriter interface {
WriteTo(bus *LogHandlerBus)
}
type Simple ¶ added in v1.0.0
type Simple struct {
// contains filtered or unexported fields
}
Simple 简单匹配
type Stdout ¶ added in v1.0.0
type Stdout struct{}
func (*Stdout) WriteTo ¶ added in v1.0.0
func (p *Stdout) WriteTo(bus *LogHandlerBus)
type Target ¶
type Target struct { No int // 自增编号 Content string // 目标内容 Excludes []string // 排除 msg To []PsLogWriter // 处理 // contains filtered or unexported fields }
Target 目标内容
type Tire ¶ added in v1.0.0
type Tire struct {
// contains filtered or unexported fields
}
字典树
type Watch ¶
type Watch struct {
// contains filtered or unexported fields
}
Watch 监听的文件
type WatchFileInfo ¶
type WatchFileInfo struct { IsDir bool // 是否为目录 Path string // 原始添加的文件路径, 这里可能是文件路径或目录路径 WatchFilePath string // 监听到的变化的文件全路径 }
WatchFileInfo
Source Files ¶
Click to show internal directories.
Click to hide internal directories.