# README
log4go
logging in Go, based on zap.
Installation
go get github.com/rumis/log4go
Note that log4go only supports the two most recent minor versions of Go, Because of zap.
Quick Start
ctx := context.TODO()
consoleLogger := log4go.NewConsoleLogger()
log4go.SetDefaultLogger(consoleLogger)
defer log4go.Sync(ctx)
log4go.Info(ctx, "failed to fetch URL",
log4go.String("url",url),
log4go.Int("attempt", 3),
log4go.Duration("backoff", time.Second))
See the documentation for more details.
Released under the MIT License.
# Functions
Bool constructs a field that carries a bool.
ByteString constructs a field that carries UTF-8 encoded text as a []byte.
Debug logs a message at DebugLevel.
DefaultOption default options.
DefaultReflectedEncoder serializes the log in json.
Duration constructs a field with the given key and value.
Error logs a message at ErrorLevel.
Fatal logs a message at FatalLevel.
FieldsConvert convert Field to zapcore.Field.
Float64 constructs a field that carries a float64.
FullCallerEncoder serializes a caller in /full/path/to/package/file:line format.
FullNameEncoder serializes the logger name as-is.
GetLogger get Logger.
Info logs a message at InfoLevel.
Int constructs a field with the given key and value.
Int64 constructs a field with the given key and value.
LowercaseLevelEncoder serializes a Level to a lowercase string.
MillisDurationEncoder serializes a time.Duration to an integer number of milliseconds elapsed.
NewConsoleLogger create a new ConsoleLogger.
NewFileLogger create new file logger.
NewGroupLogger new multi logger.
Panic logs a message at PanicLevel.
SetDefaultLogger 设置默认Logger.
SetLogger set logger.
StandTimeEncoder return TimeEncoder wich serializes a time.Time using layout 2006-01-02 15:04:05.
String constructs a field with the given key and value.
Sync flushing any buffered log entries.
Time constructs a Field with the given key and value.
TimeEncoderOfLayout returns TimeEncoder which serializes a time.Time using given layout.
Uint constructs a field with the given key and value.
Uint64 constructs a field with the given key and value.
Warn logs a message at WarnLevel.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
BoolType indicates that the field carries a bool.
ByteStringType indicates that the field carries UTF-8 encoded bytes.
DebugLevel logs are typically voluminous, and are usually disabled in production.
DurationType indicates that the field carries a time.Duration.
ErrorLevel logs are high-priority.
ErrorType indicates that the field carries an error.
FatalLevel logs a message, then calls os.Exit(1).
Float64Type indicates that the field carries a float64.
InfoLevel is the default logging priority.
Int64Type indicates that the field carries an int64.
PanicLevel logs a message, then panics.
StringType indicates that the field carries a string.
TimeFullType indicates that the field carries a time.Time stored as-is.
No description provided by the author
Uint64Type indicates that the field carries a uint64.
UnknownType is the default field type.
WarnLevel logs are more important than Info, but don't need individual human review.
# Variables
ContextFieldsKey key of context extend fields.
# Structs
ConsoleLogger console logger base on zap.
No description provided by the author
FileLogger file log base zap.
GroupLogger multi logger.
No description provided by the author
# Interfaces
Logger logger.
ReflectedEncoder serializes log fields that can't be serialized with Zap's JSON encoder.
# Type aliases
A CallerEncoder serializes an EntryCaller to a primitive type.
A DurationEncoder serializes a time.Duration to a primitive type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A LevelEncoder serializes a Level to a primitive type.
A NameEncoder serializes a period-separated logger name to a primitive type.
No description provided by the author
PrimitiveArrayEncoder is the subset of the ArrayEncoder interface that deals only in Go's built-in types.
A TimeEncoder serializes a time.Time to a primitive type.