Documentation ¶
Index ¶
- Constants
- func Database(name string) zapcore.Field
- func DurationLiteral(key string, val time.Duration) zapcore.Field
- func FromContext(ctx context.Context) *zap.Logger
- func IsTerminal(w io.Writer) bool
- func New(w io.Writer) *zap.Logger
- func NewContextWithLogger(ctx context.Context, log *zap.Logger) context.Context
- 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 RetentionPolicy(name string) zapcore.Field
- func Shard(id uint64) zapcore.Field
- func ShardGroup(id uint64) zapcore.Field
- func TraceFields(ctx context.Context) []zap.Field
- func TraceID(id string) zapcore.Field
- type Config
Constants ¶
const ( // 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" // DBRetentionKey is the logging context key used for identifying name of the relevant retention policy. DBRetentionKey = "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" // TraceIDKey is the logging context key used for identifying unique traces. TraceIDKey = "trace_id" // TraceSampledKey is the logging context key used for determining whether the current trace will be sampled. TraceSampledKey = "ot_trace_sampled" )
const TimeFormat = "2006-01-02T15:04:05.000000Z07:00"
TimeFormat represents the logger time format.
Variables ¶
This section is empty.
Functions ¶
func DurationLiteral ¶
DurationLiteral represents a duration literal from a key and time duration.
func FromContext ¶ added in v1.8.0
LoggerFromContext returns the zap.Logger associated with ctx or nil if no logger has been assigned.
func IsTerminal ¶
IsTerminal checks if w is a file and whether it is an interactive terminal session.
func NewContextWithLogger ¶ added in v1.6.0
NewContextWithLogger returns a new context with log added.
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 RetentionPolicy ¶
RetentionPolicy returns the retention policy.
func ShardGroup ¶
ShardGroup returns a field for tracking the shard group identifier.
func TraceFields ¶ added in v1.9.0
TraceFields returns a fields "ot_trace_id" and "ot_trace_sampled", values pulled from the (Jaeger) trace ID found in the given context. Returns nil if the context doesn't have a trace ID.