log

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) (*zap.Logger, error)

New creates a zap logger configured the arguments opts.

Types

type Level

type Level = zapcore.Level

type Option

type Option func(*config)

Option configures a logger.

func WithAgeDays

func WithAgeDays(maxAgeDays int) Option

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

func WithLogDirMode(mode os.FileMode) Option

WithLogDirMode sets mode and permission of log directory. Its default value is 0755.

func WithLogLevel

func WithLogLevel(level Level) Option

WithLogLevel sets log level. The default value is INFO.

func WithMaxBackups

func WithMaxBackups(maxBackups int) Option

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

func WithMaxSizeMB(maxSizeMB int) Option

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

func WithPath(path string) Option

WithPath sets a path of the log file. If this option isn't set, logging to a file will be disabled.

func WithZapLoggerOptions

func WithZapLoggerOptions(opts ...zap.Option) Option

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL