logger

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset       = "\033[0m"
	Red         = "\033[31m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Colors

Variables

This section is empty.

Functions

func CheckFileAndCreate

func CheckFileAndCreate(path string) (err error)

检查文件是否存在并且创建文件

func NewSlsLogFormPrint

func NewSlsLogFormPrint(logLevel string, args ...interface{})

func NewSlsLogFormPrintf

func NewSlsLogFormPrintf(logLevel, template string, args ...interface{})

Types

type Config

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

Config 日志配置

func DebugConfig

func DebugConfig() *Config

func (*Config) DisableFileOut

func (c *Config) DisableFileOut()

func (*Config) EnableFileOut

func (c *Config) EnableFileOut()

func (*Config) SetColorful

func (c *Config) SetColorful(colorful bool)

func (*Config) SetConsoleOut

func (c *Config) SetConsoleOut(consoleOut bool)

func (*Config) SetEnvMode

func (c *Config) SetEnvMode(envMode string)

func (*Config) SetFileOut

func (c *Config) SetFileOut(path string, maxAge, rotationTime uint)

设置 文件输出

func (*Config) SetJsonFormat

func (c *Config) SetJsonFormat(jsonFormat bool)

func (*Config) SetLevel

func (c *Config) SetLevel(level Level)

func (*Config) SetName

func (c *Config) SetName(name string)

func (*Config) SetSkip

func (c *Config) SetSkip(skip int)

type Level

type Level string
const (
	DebugLevel Level = "DEBUG"
	InfoLevel  Level = "INFO"
	WarnLevel  Level = "WARN"
	ErrorLevel Level = "ERROR"
	FatalLevel Level = "FATAL"
)

func (Level) String

func (logLevel Level) String() string

type LogKafka added in v1.3.12

type LogKafka struct {
	Topic     string
	Producer  sarama.SyncProducer
	Partition int32
}

func (*LogKafka) Write added in v1.3.12

func (lk *LogKafka) Write(p []byte) (n int, err error)

type Logger

type Logger struct {
	Config *Config
	// contains filtered or unexported fields
}

func New

func New(conf *Config) *Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug package sugar of zap

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

Debugf package sugar of zap

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error package sugar of zap

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

Errorf package sugar of zap

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal package sugar of zap

func (*Logger) Fatalf

func (l *Logger) Fatalf(template string, args ...interface{})

Fatalf package sugar of zap

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info package sugar of zap

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

Infof package sugar of zap

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic package sugar of zap

func (*Logger) Panicf

func (l *Logger) Panicf(template string, args ...interface{})

Panicf package sugar of zap

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn package sugar of zap

func (*Logger) Warnf

func (l *Logger) Warnf(template string, args ...interface{})

Warnf package sugar of zap

func (*Logger) With

func (l *Logger) With(args ...interface{}) *Logger

With adds a variadic number of fields to the logging context. see https://github.com/uber-go/zap/blob/v1.10.0/sugar.go#L91

func (*Logger) WithConfig

func (l *Logger) WithConfig(isDebug bool, kafkaSwitch bool)

根据配置文件更新 logger

Jump to

Keyboard shortcuts

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