logger

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger provides functions for setting up a zap logger with environment aware output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromConfig

func FromConfig(c Config) *zap.Logger

FromConfig constructs a new logger using the given Config.

func MilliDurationEncoder

func MilliDurationEncoder(d time.Duration, e zapcore.PrimitiveArrayEncoder)

MilliDurationEncoder encodes a time.Duration as milliseconds.

func New

func New(w zapcore.WriteSyncer) *zap.Logger

New constructs a new logger at info level printing to the given output.

func NewDevelopment

func NewDevelopment() *zap.Logger

NewDevelopment creates a logger at debug level printing to stderr.

func NewEncoder

func NewEncoder(c Config) (e zapcore.Encoder)

NewEncoder constructs a new zapcore.Encoder using the given Config.

func NewEncoderConfig

func NewEncoderConfig(c Config) zapcore.EncoderConfig

NewEncoderConfig constructs a new zapcore.EncoderConfig using the given Config.

func NewProduction

func NewProduction() *zap.Logger

NewProduction creates a new logger at info level printing to stderr.

func RFC3339MilliTimeEncoder

func RFC3339MilliTimeEncoder(t time.Time, e zapcore.PrimitiveArrayEncoder)

RFC3339MilliTimeEncoder encodes a time.Time in RFC3339 format with millisecond precision.

Types

type Config

type Config struct {
	Output zapcore.WriteSyncer
	Format Format
	Level  zapcore.Level
}

A Config describes how to construct a new logger.

type Format

type Format int

Format tells the constructors which encoder to use.

const (
	AutoFormat Format = iota
	DefaultFormat
	ConsoleFormat
	JSONFormat
)

Supported log formats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL