log

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownEnv = Env(0)
	DevEnv     = Env(iota)
	GCPEnv

	DefaultEnv = DevEnv
)

Variables

View Source
var ErrorUnkownEnv = errors.New("unknown logging environment")

Functions

func NewLogger

func NewLogger(e Env, l zapcore.Level) (*zap.Logger, error)

NewLogger returns a new instance of the zap.Logger based on the specified env and level.

The level sets the minimum level log messages will be output, with env being used to configure the logger for a particular environment.

func NewLoggerFromConfigMap

func NewLoggerFromConfigMap(defaultEnv Env, defaultLevel zapcore.Level, config map[string]string) (*zap.Logger, error)

NewLoggerFromConfigMap returns a new instance of the zap.Logger based on the value of the keys "log-env" and "log-level" in the config map.

If the "log-env" key is not present, defaultEnv will be used. If the "log-level" key is not present, defaultLevel will be used.

Types

type Env

type Env int

func LookupEnv

func LookupEnv(text string) Env

LookupEnv will return the instance of Env that corresponds to text.

If text does not match a known environment UnknownEnv will be returned.

func (Env) MarshalText

func (e Env) MarshalText() ([]byte, error)

func (Env) String

func (e Env) String() string

func (*Env) UnmarshalText

func (e *Env) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

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