zap

package
v0.0.0-...-341c48f Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package zap implements github.com/magma/magma/src/go/log via github.com/uber-go/zap

Basic usage:

import (
	uber_zap "go.uber.org/zap"

	"github.com/magma/magma/src/go/log"
	"github.com/magma/magma/src/go/log/zap"
)

lm := log.NewManager(zap.NewLogger())
lm.LoggerFor("thing").Info().Print("hello")
// Output: [thing] hello

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

Logger adapts *zap.Logger to github.com/magma/magma/src/go/log.Logger.

func New

func New(
	enc zapcore.Encoder,
	ws zapcore.WriteSyncer,
	lvl log.Level,
	opts ...zap.Option,
) *Logger

New returns a new *Logger, which satisfies magma/log.Logger. This function is available for fine-tuning logging config. For most usages, see NewLogger and NewLoggerAtLevel.

func NewLogger

func NewLogger(paths ...string) *Logger

NewLogger returns a new root *Logger with default config, outputting to the specified paths. See uber_go/zap.Open docs for more info on supported path formats.

func NewLoggerAtLevel

func NewLoggerAtLevel(lvl log.Level, paths ...string) *Logger

NewLoggerAtLevel creates a new *Logger at a specified log.Level with default console encoding outputting to the specified paths. See uber_go/zap.Open docs for more info on supported path formats.

func (*Logger) Debug

func (l *Logger) Debug() log.Printer

Debug returns a log.DebugLevel log.Printer backed by a zap.SugaredLogger.

func (*Logger) Error

func (l *Logger) Error() log.Printer

Error returns a log.ErrorLevel log.Printer backed by a zap.SugaredLogger.

func (*Logger) Info

func (l *Logger) Info() log.Printer

Info returns a log.InfoLevel log.Printer backed by a zap.SugaredLogger.

func (*Logger) Level

func (l *Logger) Level() log.Level

Level returns the currently configured log.Level.

func (*Logger) Named

func (l *Logger) Named(name string) log.Logger

Named returns a new logger scoped to the provided name.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level log.Level)

SetLevel updates the logger's log.Level. This takes effect immediately.

func (*Logger) Warning

func (l *Logger) Warning() log.Printer

Warning returns a log.WarnLevel log.Printer backed by a zap.SugaredLogger.

func (*Logger) With

func (l *Logger) With(field string, value interface{}) log.Logger

With returns a new logger with the field=value annotated on each message.

Jump to

Keyboard shortcuts

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