tlog

package
v0.0.0-...-406b1e7 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEncoderConfig = func() zapcore.EncoderConfig {
	ec := zap.NewProductionEncoderConfig()
	ec.EncodeTime = iso8601MicroTimeEncoder
	return ec
}()

DefaultEncoderConfig is the default value of zap.EncoderConfig that we use when creating top-level loggers

Functions

func Get

func Get(ctx context.Context) *zap.Logger

Get returns a logger from context

func New

func New(config Config) *zap.Logger

New creates a top-level logger.

The caller must call the returned cleanup function after using the logger.

func NewForTesting

func NewForTesting(t *testing.T) *zap.Logger

NewForTesting creates a logger for use in unit tests.

The caller must call the returned cleanup function after using the logger.

func With

func With(ctx context.Context, fields ...zapcore.Field) context.Context

With returns a context with a sub-logger with passed parameters

func WithLogger

func WithLogger(ctx context.Context, logger *zap.Logger) context.Context

WithLogger adds a logger to a context or replaces an existing one

Types

type Color

type Color string

Color is the coloring setting for text format

const (
	ColorAuto Color = ""
	ColorYes  Color = "yes"
	ColorNo   Color = "no"
)

Color values

type Config

type Config struct {
	Name    string // top-level logger name (optional)
	Format  Format
	Color   Color
	Verbose bool // enable messages at Debug level
}

Config is the configuration for creating a top-level logger

type Format

type Format string

Format is the logging format

const (
	FormatJSON Format = "json"
	FormatText Format = "text"
)

Format values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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