Documentation ¶
Index ¶
Constants ¶
View Source
const ( // PeriodHourly rotates log every hour PeriodHourly period = "hourly" // PeriodDaily rotates log by every day PeriodDaily period = "daily" // PeriodWeekly rotates log by every week PeriodWeekly period = "weekly" // PeriodMonthly rotates log by every month PeriodMonthly period = "monthly" )
Variables ¶
View Source
var ( DefaultArchiveTimeFormat = "2006-01-02_15:04:05.000" DefaultMaxArchives = 100 DefaultMaxArchiveDays = 14 )
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a logger with rotation function
type Option ¶
type Option func(*Options)
func ArchiveTimeFormat ¶
func MaxArchiveDays ¶
func MaxArchives ¶
func RotatePeriod ¶
func RotatePeriod(p period) Option
func RotateSize ¶
type Options ¶
type Options struct { // File is the file to write logs to. // It uses <process name>.log in os.TempDir() if empty. File string `json:"file" toml:"file" yaml:"file"` // RotatePeriod is time period for rotate log. // It supports hourly, daily, weekly, monthly. RotatePeriod string `json:"rotate_period" toml:"rotate_period" yaml:"rotate_period"` // RotateSize is the maximum size of the log file before it gets rotated RotateSize string `json:"rotate_size" toml:"rotate_size" yaml:"rotate_size"` // MaxArchives is the maximum number of old log files to retain MaxArchives int `json:"max_archives" toml:"max_archives" yaml:"max_archives"` // MaxArchiveDays is the maximum number of days to archived files MaxArchiveDays int `json:"max_archive_days" toml:"max_archive_days" yaml:"max_archive_days"` // ArchiveTimeFormat is the format of the archived files ArchiveTimeFormat string `json:"archive_time_format" toml:"archive_time_format" yaml:"archive_time_format"` // Compress determines if the rotated log files should be compressed // using gzip. The default is not to perform compression. Compress bool `json:"compress" toml:"compress" yaml:"compress"` // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.