Documentation
¶
Index ¶
Constants ¶
View Source
const ( // no rolling PolicyWithoutRolling = iota // rolling by time PolicyTimeRolling // rolling by file size PolicyFileSizeRolling )
3 policy for rolling
View Source
const ( WriteModeNone = iota WriteModeLock WriteModeBuffered )
View Source
const ( // default open file mode is rw-r--r-- DefaultFileMode = os.FileMode(0644) DefaultFileFlag = os.O_RDWR | os.O_CREATE | os.O_APPEND DefaultFileTagFormat = "200601021504" DefaultFileBytesStr = "512M" DefaultFileBytes = 1024 * 1024 * 512 DefaultFileSizeCheckDuration = 1 // default buffer size is 1M DefaultBufferSize = 1024 * 1024 * 1 )
Variables ¶
View Source
var ( ErrInvalidOption = errors.New("invalid option") ErrOther = errors.New("other error") )
Functions ¶
This section is empty.
Types ¶
type BaseLogger ¶
type BaseLogger struct {
// contains filtered or unexported fields
}
func (*BaseLogger) Close ¶
func (b *BaseLogger) Close() error
func (*BaseLogger) ReOpen ¶
func (b *BaseLogger) ReOpen(fileName string) error
type BufferLogger ¶
type BufferLogger struct {
BaseLogger
// contains filtered or unexported fields
}
func (*BufferLogger) Close ¶
func (b *BufferLogger) Close() error
type LockLogger ¶
type LockLogger struct {
BaseLogger
sync.Mutex
}
func (*LockLogger) Close ¶
func (l *LockLogger) Close() error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager used to trigger rolling event.
func NewManager ¶
type Option ¶
type Option struct {
// the LogPath & FileName define the full path of the log.
// the current log is located at [LogPath]/[FileName].log
// the truncated log is located at [LogPath]/[FileName].log.[tag]
LogPath string `json:"log_path"`
FileName string `json:"file_name"`
RollingPolicy int `json:"rolling_policy"`
// cron job like pattern, for time policy
RollingCronJobPattern string `json:"rolling_cron_job_pattern"`
// file size to start rolling, for file size policy
RollingFileBytes string `json:"rolling_file_bytes"`
WriteMode int `json:"write_mode"`
BufferSize int `json:"buffer_size"`
}
func NewDefaultOption ¶
func NewDefaultOption() Option
func (*Option) ComputeRollingFileSize ¶
func (*Option) LogFilePath ¶
Click to show internal directories.
Click to hide internal directories.