Documentation ¶
Index ¶
- Constants
- func Database(name string) zapcore.Field
- func Debug(msg string, fields ...zap.Field)
- func DurationLiteral(key string, val time.Duration) zapcore.Field
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func InitZapLogger(cfg *Config) error
- func L() *zap.Logger
- func NewLoggerWithConfigAndWriter(config *Config, w io.Writer, opts ...zap.Option) (*zap.Logger, error)
- func NewLoggerWithWriter(w io.Writer, opts ...zap.Option) *zap.Logger
- func NewOperation(log *zap.Logger, msg, name string, fields ...zapcore.Field) (*zap.Logger, func())
- func OperationElapsed(d time.Duration) zapcore.Field
- func OperationEventEnd() zapcore.Field
- func OperationEventStart() zapcore.Field
- func OperationName(name string) zapcore.Field
- func Panic(msg string, fields ...zap.Field)
- func RetentionPolicy(name string) zapcore.Field
- func S() *zap.SugaredLogger
- func Shard(id uint64) zapcore.Field
- func ShardGroup(id uint64) zapcore.Field
- func TraceID(id string) zapcore.Field
- func Warn(msg string, fields ...zap.Field)
- func With(fields ...zap.Field) *zap.Logger
- type Config
- type LogFileConfig
Constants ¶
const ( DefaultLogTimeFormat = "2006-01-02T15:04:05.000000Z07:00" // DefaultLogFormat is the default format of the log. DefaultLogFormat = "text" DefaultLogLevel = zapcore.InfoLevel // DefaultLogMaxSize is the default size of log files. DefaultLogMaxSize = 300 // MB )
const ( // TraceIDKey is the logging context key used for identifying unique traces. TraceIDKey = "trace_id" // OperationNameKey is the logging context key used for identifying name of an operation. OperationNameKey = "op_name" // OperationEventKey is the logging context key used for identifying a notable // event during the course of an operation. OperationEventKey = "op_event" // OperationElapsedKey is the logging context key used for identifying time elapsed to finish an operation. OperationElapsedKey = "op_elapsed" // DBInstanceKey is the logging context key used for identifying name of the relevant database. DBInstanceKey = "db_instance" // DBRetentionPolicyKey is the logging context key used for identifying name of the relevant retention policy. DBRetentionPolicyKey = "db_rp" // DBShardGroupKey is the logging context key used for identifying relevant shard group. DBShardGroupKey = "db_shard_group" // DBShardIDKey is the logging context key used for identifying name of the relevant shard number. DBShardIDKey = "db_shard_id" )
Variables ¶
This section is empty.
Functions ¶
func Debug ¶ added in v1.0.1
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func DurationLiteral ¶ added in v1.0.1
DurationLiteral represents a duration literal from a key and time duration.
func Error ¶ added in v1.0.1
Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Fatal ¶ added in v1.0.1
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func Info ¶ added in v1.0.1
Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func InitZapLogger ¶
func L ¶ added in v1.0.1
L returns the global Logger, which can be reconfigured with ReplaceGlobals. It's safe for concurrent use.
func NewLoggerWithConfigAndWriter ¶ added in v1.0.1
func NewLoggerWithConfigAndWriter(config *Config, w io.Writer, opts ...zap.Option) (*zap.Logger, error)
NewLoggerWithConfigAndWriter creates a new zap.Logger with a Config and an io.Writer
func NewLoggerWithWriter ¶ added in v1.0.1
NewLoggerWithWriter creates a new zap.Logger with an io.Writer
func NewOperation ¶
NewOperation uses the exiting log to create a new logger with context containing a trace id and the operation. Prior to returning, a standardized message is logged indicating the operation has started. The returned function should be called when the operation concludes in order to log a corresponding message which includes an elapsed time and that the operation has ended.
func OperationElapsed ¶
OperationElapsed returns a field for tracking the duration of an operation.
func OperationEventEnd ¶
OperationEventEnd returns a field for tracking the end of an operation.
func OperationEventStart ¶
OperationEventStart returns a field for tracking the start of an operation.
func OperationName ¶
OperationName returns a field for tracking the name of an operation.
func Panic ¶ added in v1.0.1
Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then panics, even if logging at PanicLevel is disabled.
func RetentionPolicy ¶
RetentionPolicy returns the retention policy.
func S ¶ added in v1.0.1
func S() *zap.SugaredLogger
S returns the global SugaredLogger, which can be reconfigured with ReplaceGlobals. It's safe for concurrent use.
func ShardGroup ¶
ShardGroup returns a field for tracking the shard group identifier.
Types ¶
type Config ¶
func NewDefaultLogConfig ¶
func NewDefaultLogConfig() *Config
func NewLogConfig ¶
func NewLogConfig(level zapcore.Level, format string, fileCfg LogFileConfig, disableTimestamp bool, opts ...func(*zaputil.Config)) *Config
NewLogConfig "comment"
type LogFileConfig ¶
type LogFileConfig struct {
zaputil.FileConfig
}
func NewLogFileConfig ¶
func NewLogFileConfig(maxSize uint) LogFileConfig
NewLogFileConfig "comment"