zapwriter

package module
v0.0.0-...-3315bf1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2017 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

zapwriter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMixedEncoder

func NewMixedEncoder(formatter ...MixedFormatter) zap.Encoder

NewMixedEncoder creates a fast, low-allocation JSON encoder. By default, JSON encoders put the log message under the "msg" key, the timestamp (as floating-point seconds since epoch) under the "ts" key, and the log level under the "level" key. The encoder appropriately escapes all field keys and values.

Note that the encoder doesn't deduplicate keys, so it's possible to produce a message like

{"foo":"bar","foo":"baz"}

This is permitted by the JSON specification, but not encouraged. Many libraries will ignore duplicate key-value pairs (typically keeping the last pair) when unmarshaling, but users should attempt to avoid adding duplicate keys.

Types

type FileOutput

type FileOutput struct {
	sync.Mutex
	// contains filtered or unexported fields
}

with external rotate support

func File

func File(path string) (*FileOutput, error)

func (*FileOutput) Close

func (r *FileOutput) Close() (err error)

func (*FileOutput) Sync

func (r *FileOutput) Sync() (err error)

func (*FileOutput) Write

func (r *FileOutput) Write(p []byte) (n int, err error)

type MixedFormatter

type MixedFormatter func(time.Time, zap.Level, string) string

type Output

type Output interface {
	io.Writer
	Sync() error
}

func New

func New(dsn string) (Output, error)

Jump to

Keyboard shortcuts

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