logger

package
v0.0.0-...-3d3f4ff Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

README

logger

Logger leverages uber/zap for best performance and availability.

Example

Production JSON format in error level:

logger := logger.New(logger.Level("error")).Sugar()
defer logger.Sync()
logger.Errorw("failed to fetch URL",
  // Structured context as loosely typed key-value pairs.
  "url", url,
  "attempt", 3,
  "backoff", time.Second,
)
// {"level":"error","ts":1589648882.6028602,"msg":"failed to fetch URL","url":"https://localhost/foo","attempt":3,"backoff":1}

Development console print format in debug level:

logger := logger.New(logger.Level("debug"), logger.Encoder("console")).Sugar()
defer logger.Sync()
logger.Debugw("failed to fetch URL",
  // Structured context as loosely typed key-value pairs.
  "url", url,
  "attempt", 3,
  "backoff", time.Second,
)
// 2020-05-16T19:09:41.991+0200    Debug   failed to fetch URL     {"url": "https://localhost/foo", "attempt": 3, "backoff": "1s"}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(setters ...Option) *zap.Logger

New zap logger

Types

type Option

type Option func(*Options)

func Encoder

func Encoder(format string) Option

func Level

func Level(level string) Option

type Options

type Options struct {
	Level   zapcore.Level
	Encoder zapcore.Encoder
}

Jump to

Keyboard shortcuts

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