Documentation
¶
Index ¶
- Variables
- func Configz(msg string, fields ...zap.Field)
- func Criz(msg string, fields ...zap.Field)
- func Debugf(msg string, args ...interface{})
- func Debugz(msg string, fields ...zap.Field)
- func DisableRotates()
- func Errorf(msg string, args ...interface{})
- func Errorz(msg string, fields ...zap.Field)
- func Errorzc(ctx context.Context, msg string, fields ...zap.Field)
- func Errorzo(option zap.Option, msg string, fields ...zap.Field)
- func Infof(msg string, args ...interface{})
- func Infoz(msg string, fields ...zap.Field)
- func Infozc(ctx context.Context, msg string, fields ...zap.Field)
- func Infozo(option zap.Option, msg string, fields ...zap.Field)
- func IsDebugEnabled() bool
- func Metaz(msg string, fields ...zap.Field)
- func Metazo(option zap.Option, msg string, fields ...zap.Field)
- func SetupZapLogger()
- func Stat(msg string)
- func Warnf(msg string, args ...interface{})
- func Warnz(msg string, fields ...zap.Field)
- func WithLogCtx(ctx context.Context, option zap.Option) context.Context
- type FileIndex
- type LogConfig
- type LoggerComposite
- type RotateWriter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ZapLogger = &LoggerComposite{} DebugEnabled = false )
Functions ¶
func DisableRotates ¶
func DisableRotates()
func IsDebugEnabled ¶
func IsDebugEnabled() bool
func SetupZapLogger ¶
func SetupZapLogger()
Types ¶
type LogConfig ¶
type LogConfig struct {
// Filename is the file to write logs to. Backup log files will be retained
// in the same directory. It uses format '${filename}.${date}.${index}'
Filename string
// MaxSize is the max size of a log file before being rotated.
MaxSize int64
// MaxBackupCount is the max count of backup files.
// Backup files are files with name format '${filename}.${date}.${index}'.
// Only recent MaxBackupCount log files will be retained.
MaxBackupCount int
// MaxBackupsSize is the max accumulated size of backup files.
// Only recent N log files whose accumulated size <= MaxBackupsSize will be retained.
MaxBackupsSize int64
// TimeLayout is the layout used when make a backup log files.
TimeLayout string
// Remove unknown files that match '${filename}.*' but '${date}' part is not matched to timeLayout
// For example, 'a.log.2022-01-01_17.1' is not matched to '2006-01-02' pattern. This happens after changing to the timeLayout.
RemoveUnknownFiles bool
// DeleteScanPatterns are patterns to scan when search and delete backups.
DeleteScanPatterns []string
// FileIndex is used to control index of backup files.
// When set to 'min' , a.log.${time}.${index} will be rename to a.log.${time}.${index+1}, and a.log will be rename to a.log.${time}.1
// When set to 'min' , a.log will be rename to a.log.${time}.${maxIndex+1}
// see https://logging.apache.org/log4j/2.x/manual/appenders.html
// Defaults to 'min'
FileIndex FileIndex
}
type LoggerComposite ¶
type RotateWriter ¶
type RotateWriter struct {
// contains filtered or unexported fields
}
RotateWriter is an io.Writer with ability to rotate files by timer and size like LOG4J in Java. Some codes are copied from 'gopkg.in/natefinch/lumberjack.v2 v2.0.0'. The entire rotation process is not atomic. If a crash happens when rotating, it may leave an intermediate state.
func NewRotateWriter ¶
func NewRotateWriter(cfg LogConfig) (*RotateWriter, error)
func (*RotateWriter) Close ¶
func (w *RotateWriter) Close() error
Click to show internal directories.
Click to hide internal directories.