Documentation ¶
Index ¶
- Constants
- Variables
- func CustomTimeFormat(t time.Time, format string) string
- func DefaultTimeFormat(t time.Time) []byte
- func GetLogEncoderKey(defKey, key string) string
- func NewTimeEncoder(format string) zapcore.TimeEncoder
- func NewZapLog(c xlog.Config) xlog.Logger
- func NewZapLogWithCallerSkip(cfg xlog.Config, callerSkip int) xlog.Logger
- func RedirectStdLog(logger xlog.Logger) (func(), error)
- func RedirectStdLogAt(logger xlog.Logger, level zapcore.Level) (func(), error)
- type ConsoleWriterFactory
- type Decoder
- type Factory
- type FileWriterFactory
Constants ¶
const ( ConsoleZapCore = "console" FileZapCore = "file" )
Some ZapCore constants.
Variables ¶
var ( Levels = map[string]zapcore.Level{ "": zapcore.DebugLevel, "trace": zapcore.DebugLevel, "debug": zapcore.DebugLevel, "info": zapcore.InfoLevel, "warn": zapcore.WarnLevel, "error": zapcore.ErrorLevel, "fatal": zapcore.FatalLevel, "panic": zapcore.PanicLevel, } )
Functions ¶
func CustomTimeFormat ¶
CustomTimeFormat customize time format. Deprecated: Use https://pkg.go.dev/time#Time.Format instead.
func DefaultTimeFormat ¶
DefaultTimeFormat returns the default time format "2006-01-02 15:04:05.000". Deprecated: Use https://pkg.go.dev/time#Time.AppendFormat instead.
func GetLogEncoderKey ¶
GetLogEncoderKey gets user defined log output name, uses defKey if empty.
func NewTimeEncoder ¶
func NewTimeEncoder(format string) zapcore.TimeEncoder
NewTimeEncoder creates a time format encoder.
func NewZapLogWithCallerSkip ¶
NewZapLogWithCallerSkip creates a default Logger from zap.
func RedirectStdLog ¶
RedirectStdLog redirects std log to trpc logger as log level INFO. After redirection, log flag is zero, the prefix is empty. The returned function may be used to recover log flag and prefix, and redirect output to os.Stderr.
func RedirectStdLogAt ¶
RedirectStdLogAt redirects std log to trpc logger with a specific level. After redirection, log flag is zero, the prefix is empty. The returned function may be used to recover log flag and prefix, and redirect output to os.Stderr.
Types ¶
type ConsoleWriterFactory ¶
type ConsoleWriterFactory struct { }
ConsoleWriterFactory is the console writer instance.
func (*ConsoleWriterFactory) Setup ¶
func (f *ConsoleWriterFactory) Setup(name string, dec plugin.Decoder) error
Setup starts, loads and registers console output writer.
func (*ConsoleWriterFactory) Type ¶
func (f *ConsoleWriterFactory) Type() string
Type returns the log plugin type.
type Decoder ¶
type Decoder struct { OutputConfig *xlog.OutputConfig Core zapcore.Core ZapLevel zap.AtomicLevel }
Decoder decodes the log.
type Factory ¶
type Factory struct{}
Factory is the log plugin factory. When server start, the configuration is feed to Factory to generate a log instance.
type FileWriterFactory ¶
type FileWriterFactory struct { }
FileWriterFactory is the file writer instance Factory.
func (*FileWriterFactory) Setup ¶
func (f *FileWriterFactory) Setup(name string, dec plugin.Decoder) error
Setup starts, loads and register file output writer.
func (*FileWriterFactory) Type ¶
func (f *FileWriterFactory) Type() string
Type returns log file type.