logger

package
v0.0.0-...-7ca97a9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZapLogger    = &LoggerComposite{}
	DebugEnabled = false
)

Functions

func Configz

func Configz(msg string, fields ...zap.Field)

func Criz

func Criz(msg string, fields ...zap.Field)

Criz prints logs to Cri.log

func Debugf

func Debugf(msg string, args ...interface{})

func Debugz

func Debugz(msg string, fields ...zap.Field)

func DisableRotates

func DisableRotates()

func Errorf

func Errorf(msg string, args ...interface{})

func Errorz

func Errorz(msg string, fields ...zap.Field)

func Errorzc

func Errorzc(ctx context.Context, msg string, fields ...zap.Field)

func Errorzo

func Errorzo(option zap.Option, msg string, fields ...zap.Field)

func Infof

func Infof(msg string, args ...interface{})

func Infoz

func Infoz(msg string, fields ...zap.Field)

func Infozc

func Infozc(ctx context.Context, msg string, fields ...zap.Field)

func Infozo

func Infozo(option zap.Option, msg string, fields ...zap.Field)

func IsDebugEnabled

func IsDebugEnabled() bool

func Metaz

func Metaz(msg string, fields ...zap.Field)

func Metazo

func Metazo(option zap.Option, msg string, fields ...zap.Field)

func SetupZapLogger

func SetupZapLogger()

func Stat

func Stat(msg string)

func Warnf

func Warnf(msg string, args ...interface{})

func Warnz

func Warnz(msg string, fields ...zap.Field)

func WithLogCtx

func WithLogCtx(ctx context.Context, option zap.Option) context.Context

Types

type FileIndex

type FileIndex uint8
const (
	FileIndexMin FileIndex = iota
	FileIndexMax
)

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 LoggerComposite struct {
	Debug  *zap.Logger
	DebugS *zap.SugaredLogger
	Info   *zap.Logger
	InfoS  *zap.SugaredLogger
	Warn   *zap.Logger
	WarnS  *zap.SugaredLogger
	Error  *zap.Logger
	ErrorS *zap.SugaredLogger
	Stat   *zap.Logger
	Config *zap.Logger
	Meta   *zap.Logger
	MetaS  *zap.SugaredLogger
	Cri    *zap.Logger
}

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

func (*RotateWriter) Write

func (w *RotateWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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