logger

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

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsoleLogger

func ConsoleLogger() *zap.Logger

ConsoleLogger 控制台输出

func Initializer

func Initializer(consoleLogger, fileLogger *zap.Logger)

Initializer 初始化日志

func Logger

func Logger() (*zap.Logger, *zap.Logger)

Logger 获取日志

func New

func New(logger *zap.Logger, config Configuration) (*zap.Logger, *zap.Logger)

New 创建日志控制器

func NewJSONFileLogger

func NewJSONFileLogger(logger *zap.Logger, config Configuration, level zapcore.Level, format LoggingFormat) *zap.Logger

NewJSONFileLogger file

func NewJSONLogger

func NewJSONLogger(output *os.File, level zapcore.Level, format LoggingFormat) *zap.Logger

NewJSONLogger 创建json格式输出日志

func NewMultiLogger

func NewMultiLogger(loggers ...*zap.Logger) *zap.Logger

NewMultiLogger 多日志创建

func NewRotatingJSONFileLogger

func NewRotatingJSONFileLogger(logger *zap.Logger, config Configuration, level zapcore.Level, format LoggingFormat) *zap.Logger

NewRotatingJSONFileLogger 创建滚动式日志文件存储

func RedirectStdLog

func RedirectStdLog(logger *zap.Logger)

func StackdriverLevelEncoder

func StackdriverLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

StackdriverLevelEncoder stackdriver Level encoder

func StartupLogger

func StartupLogger() *zap.Logger

ConsoleLogger 控制台输出

Types

type Configuration

type Configuration struct {
	Level      string `yaml:"level" json:"level" usage:"Log level to set. Valid values are 'debug', 'info', 'warn', 'error'. Default 'info'."`
	Stdout     bool   `yaml:"stdout" json:"stdout" usage:"Log to standard console output (as well as to a file if set). Default true."`
	File       string `` /* 135-byte string literal not displayed */
	Rotation   bool   `yaml:"rotation" json:"rotation" usage:"Rotate log files. Default is false."`
	MaxSize    int    `` /* 139-byte string literal not displayed */
	MaxAge     int    `` /* 195-byte string literal not displayed */
	MaxBackups int    `` /* 188-byte string literal not displayed */
	LocalTime  bool   `` /* 184-byte string literal not displayed */
	Compress   bool   `yaml:"compress" json:"compress" usage:"This determines if the rotated log files should be compressed using gzip."`
	Format     string `yaml:"format" json:"format" usage:"Set logging output format. Can either be 'JSON' or 'Stackdriver'. Default is 'JSON'."`
}

Configuration 日志配置信息

func NewConfiguration

func NewConfiguration() Configuration

func (*Configuration) Check

func (c *Configuration) Check() error

Check 检查配置文件

type LoggingFormat

type LoggingFormat int8

定义日志输出格式

const (
	// JSONFormat json格式输出
	JSONFormat LoggingFormat = iota - 1

	// StackdriverFormat Stackdriver
	StackdriverFormat
)

type RedirectStdLogWriter

type RedirectStdLogWriter struct {
	// contains filtered or unexported fields
}

func (*RedirectStdLogWriter) Write

func (r *RedirectStdLogWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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