log

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WriterStdOut
	WriterStdOut = "stdout"
	// WriterFile
	WriterFile = "file"
)
View Source
const (
	// RotateTimeDaily
	RotateTimeDaily = "daily"
	// RotateTimeHourly
	RotateTimeHourly = "hourly"
)
View Source
const (
	// InstanceZapLogger zap logger
	InstanceZapLogger int = iota
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug logger

func Debugf

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

Debugf logger

func Error

func Error(args ...interface{})

Error logger

func Errorf

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

Errorf logger

func Fatal

func Fatal(args ...interface{})

Fatal logger

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logger

func Info

func Info(args ...interface{})

Info logger

func Infof

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

Infof logger

func NewLogger

func NewLogger(cfg *Config, loggerInstance int) error

NewLogger returns an instance of logger

func Panicf

func Panicf(format string, args ...interface{})

Panicf logger

func Warn

func Warn(args ...interface{})

Warn logger

func Warnf

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

Warnf logger

Types

type Config

type Config struct {
	Writers          string `yaml:"writers"`
	LoggerLevel      string `yaml:"logger_level"`
	LoggerFile       string `yaml:"logger_file"`
	LoggerWarnFile   string `yaml:"logger_warn_file"`
	LoggerErrorFile  string `yaml:"logger_error_file"`
	LogFormatText    bool   `yaml:"log_format_text"`
	LogRollingPolicy string `yaml:"log_rolling_policy"`
	LogRotateDate    int    `yaml:"log_rotate_date"`
	LogRotateSize    int    `yaml:"log_rotate_size"`
	LogBackupCount   int    `yaml:"log_backup_count"`
}

Config is the struct for logger information

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type Logger

type Logger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
	WithFields(keyValues Fields) Logger
}

Logger is our contract for the logger

func WithFields

func WithFields(keyValues Fields) Logger

WithFields logger output more field, eg:

contextLogger := coloredoutput.WithFields(coloredoutput.Fields{"key1": "value1"})
contextLogger.Info("print multi field")

or more sample to use:

coloredoutput.WithFields(coloredoutput.Fields{"key1": "value1"}).Info("this is a test coloredoutput")
coloredoutput.WithFields(coloredoutput.Fields{"key1": "value1"}).Infof("this is a test coloredoutput,
user_id: %d", userID)

Jump to

Keyboard shortcuts

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