Documentation ¶
Index ¶
- func New(opts ...Option) (*zap.Logger, error)
- type Level
- type Option
- func WithAgeDays(maxAgeDays int) Option
- func WithCompression() Option
- func WithHumanFriendly() Option
- func WithLocalTime() Option
- func WithLogDirMode(mode os.FileMode) Option
- func WithLogLevel(level Level) Option
- func WithMaxBackups(maxBackups int) Option
- func WithMaxSizeMB(maxSizeMB int) Option
- func WithPath(path string) Option
- func WithZapLoggerOptions(opts ...zap.Option) Option
- func WithZapSampling(zapSampling *zap.SamplingConfig) Option
- func WithoutLogToStderr() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*config)
Option configures a logger.
func WithAgeDays ¶
WithAgeDays sets the retention of log files in days. There is no retention rule based on age if this option is not set.
func WithCompression ¶
func WithCompression() Option
WithCompression makes the old log files compressed. Old files are not compressed if this option is not set.
func WithHumanFriendly ¶
func WithHumanFriendly() Option
WithHumanFriendly makes the logger print logs in a human-friendly format. This option prints logs in text format rather than JSON and times in ISO8601 format rather than UNIX time format.
func WithLocalTime ¶
func WithLocalTime() Option
WithLocalTime sets the local time to the timestamp in log file names. UTC will be used if this option is not set.
func WithLogDirMode ¶
WithLogDirMode sets mode and permission of log directory. Its default value is 0755.
func WithLogLevel ¶
WithLogLevel sets log level. The default value is INFO.
func WithMaxBackups ¶
WithMaxBackups sets the maximum number of files to retain. There is no retention rule based on the number of files if this option is not set.
func WithMaxSizeMB ¶
WithMaxSizeMB sets the maximum size of a log file in megabytes. If a log file increases more than the maxSizeMB, it will be rotated. Its default value is 100 megabytes.
func WithPath ¶
WithPath sets a path of the log file. If this option isn't set, logging to a file will be disabled.
func WithZapLoggerOptions ¶
WithZapLoggerOptions sets options for zap logger.
func WithZapSampling ¶
func WithZapSampling(zapSampling *zap.SamplingConfig) Option
WithZapSampling sets sampling options for zap logger.
func WithoutLogToStderr ¶
func WithoutLogToStderr() Option
WithoutLogToStderr disalbes logging to stderr.