clogger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DPanic

func DPanic(template string, args ...interface{})

DPanic uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)

func DPanicw

func DPanicw(msg string, keysAndValues ...interface{})

DPanicw logs a message with some additional context. In development, the logger then panics. (See DPanicLevel for details.) The variadic key-value pairs are treated as they are in With.

func Debug

func Debug(template string, args ...interface{})

Debug uses fmt.Sprintf to log a templated message.

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

When debug-level logging is disabled, this is much faster than

s.With(keysAndValues).Debug(msg)

func Enable

func Enable(level zapcore.Level) bool

func Error

func Error(template string, args ...interface{})

Error uses fmt.Sprintf to log a templated message.

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

func Fatal

func Fatal(template string, args ...interface{})

Fatal uses fmt.Sprintf to log a templated message, then calls os.Exit.

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

Fatalw logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With.

func Flush

func Flush()

func GetLevel

func GetLevel(level string) zapcore.Level

func Info

func Info(template string, args ...interface{})

Info uses fmt.Sprintf to log a templated message.

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

func NewSugaredLogger

func NewSugaredLogger(core zapcore.Core, opts ...zap.Option) *zap.SugaredLogger

func Panic

func Panic(template string, args ...interface{})

Panic uses fmt.Sprintf to log a templated message, then panics.

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

Panicw logs a message with some additional context, then panics. The variadic key-value pairs are treated as they are in With.

func PrintLevel

func PrintLevel(level zapcore.Level) bool

func SetFileNameVar

func SetFileNameVar(key, value string)

func SetNodeLogger

func SetNodeLogger(node cfacade.INode)

func Warn

func Warn(template string, args ...interface{})

Warn uses fmt.Sprintf to log a templated message.

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

Types

type ActorLogger

type ActorLogger struct {
	*zap.SugaredLogger
	*Config
}
var (
	DefaultLogger *ActorLogger // 默认日志对象(控制台输出)

)

func NewConfigLogger

func NewConfigLogger(config *Config, opts ...zap.Option) *ActorLogger

func NewLogger

func NewLogger(refLoggerName string, opts ...zap.Option) *ActorLogger

func (*ActorLogger) Print

func (c *ActorLogger) Print(v ...interface{})

type Config

type Config struct {
	LogLevel        string `json:"level"`             // 输出日志等级
	StackLevel      string `json:"stack_level"`       // 堆栈输出日志等级
	EnableConsole   bool   `json:"enable_console"`    // 是否控制台输出
	EnableWriteFile bool   `json:"enable_write_file"` // 是否输出文件(必需配置FilePath)
	MaxAge          int    `json:"max_age"`           // 最大保留天数(达到限制,则会被清理)
	TimeFormat      string `json:"time_format"`       // 打印时间输出格式
	PrintCaller     bool   `json:"print_caller"`      // 是否打印调用函数
	RotationTime    int    `json:"rotation_time"`     // 日期分割时间(秒)
	FileLinkPath    string `json:"file_link_path"`    // 日志文件连接路径
	FilePathFormat  string `json:"file_path_format"`  // 日志文件路径格式
	IncludeStdout   bool   `json:"include_stdout"`    // 是否包含os.stdout输出
	IncludeStderr   bool   `json:"include_stderr"`    // 是否包含os.stderr输出
}

func NewConfig

func NewConfig(jsonConfig cfacade.ProfileJSON) (*Config, error)

func NewConfigWithName

func NewConfigWithName(refLoggerName string) (*Config, error)

func (*Config) TimeEncoder

func (c *Config) TimeEncoder() zapcore.TimeEncoder

Directories

Path Synopsis
Package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.
Package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.

Jump to

Keyboard shortcuts

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