Documentation ¶
Index ¶
Constants ¶
const DefaultLogTimeFormat = "2006-01-02 15:04:05.000"
DefaultLogTimeFormat defines the timestamp format.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConsoleHook ¶
type ConsoleHook struct {
// contains filtered or unexported fields
}
ConsoleHook shows logs on console.
func (*ConsoleHook) Fire ¶
func (ch *ConsoleHook) Fire(entry *logrus.Entry) error
Fire implements Hook#Fire.
func (*ConsoleHook) Levels ¶
func (ch *ConsoleHook) Levels() []logrus.Level
Levels implements Hook#Levels().
type DragonflyFormatter ¶
type DragonflyFormatter struct { // TimestampFormat sets the format used for marshaling timestamps. TimestampFormat string Sign string }
DragonflyFormatter customizes the dragonfly log format.
type LogConfig ¶ added in v1.0.0
type LogConfig struct { // MaxSize is the maximum size in megabytes of the log file before it gets rotated. // It defaults to 40 megabytes. MaxSize int `yaml:"maxSize" json:"maxSize"` // MaxBackups is the maximum number of old log files to retain. // The default value is 1. MaxBackups int `yaml:"maxBackups" json:"maxBackups"` // Path is the location of log file // The default value is logs/dfdaemon.log Path string `yaml:"path" json:"path"` }
LogConfig holds all configurable properties of log.
type Option ¶ added in v1.0.0
Option is a functional configuration for the given logrus logger.
func WithConsole ¶ added in v1.0.0
func WithConsole() Option
WithConsole adds a hook to output logs to stdout.
func WithLogFile ¶ added in v1.0.0
WithLogFile sets the logger to output to the given file, with log rotation.
If the given file is empty, nothing will be done.
The maxSize is the maximum size in megabytes of the log file before it gets rotated. It defaults to 40 megabytes.
The maxBackups is the maximum number of old log files to retain. The default value is 1.
func WithMaxSizeMB ¶ added in v1.0.0
WithMaxSizeMB sets the max size of log files in MB. If the logger is not configured to use a log file, an error is returned.