Documentation ¶
Index ¶
- Constants
- Variables
- func Attach(rootCmd *cobra.Command)
- func Clock() zapcore.Clock
- func Module(module string) func(ctx context.Context) Logger
- func NewStdConsoleEncoder(ec StdConsoleEncoderConfig) zapcore.Encoder
- func PreciseTimeEncoder() zapcore.TimeEncoder
- func TimezoneAdjust(inner zapcore.TimeEncoder, isLocal bool) zapcore.TimeEncoder
- func WithAdditionalLogger(ctx context.Context, fact LoggerFactory) context.Context
- func WithLogger(ctx context.Context, l LoggerFactory) context.Context
- type Logger
- type LoggerFactory
- type StdConsoleEncoderConfig
Constants ¶
const PreciseLayout = "2006-01-02T15:04:05.000000Z07:00"
PreciseLayout is a variant of time.RFC3339Nano but with microsecond precision and trailing zeroes.
Variables ¶
var NullLogger = zap.NewNop().Sugar()
NullLogger represents a singleton logger that discards all output.
Functions ¶
func Module ¶
Module returns an function that returns a logger for a given module when provided with a context.
func NewStdConsoleEncoder ¶
func NewStdConsoleEncoder(ec StdConsoleEncoderConfig) zapcore.Encoder
NewStdConsoleEncoder returns standardized console encoder which is optimized for performance.
func PreciseTimeEncoder ¶
func PreciseTimeEncoder() zapcore.TimeEncoder
PreciseTimeEncoder encodes the time as RFC3389 with 6 digits of sub-second precision.
func TimezoneAdjust ¶
func TimezoneAdjust(inner zapcore.TimeEncoder, isLocal bool) zapcore.TimeEncoder
TimezoneAdjust returns zapcore.TimeEncoder that adjusts the time to either UTC or local time before logging.
func WithAdditionalLogger ¶
func WithAdditionalLogger(ctx context.Context, fact LoggerFactory) context.Context
WithAdditionalLogger returns a context where all logging is emitted the original output plus the provided logger factory.
func WithLogger ¶
func WithLogger(ctx context.Context, l LoggerFactory) context.Context
WithLogger returns a derived context with associated logger.
Types ¶
type LoggerFactory ¶
LoggerFactory retrieves a named logger for a given module.
var (
DefaultLoggerFactory LoggerFactory
)
func ToWriter ¶
func ToWriter(w io.Writer) LoggerFactory
ToWriter returns LoggerFactory that uses given writer for log output (unadorned).