logging

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

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

Go to latest
Published: Sep 28, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Zap *zap.Logger //nolint:gochecknoglobals

Functions

func FromContext

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

func New

func New(appID string, cfg *Config) (*zap.Logger, error)

func Setup

func Setup(appID string, cfg *Config)

func ToContext

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

func ZapFieldPkg

func ZapFieldPkg(pkg string) zapcore.Field

Types

type BadgerLogger

type BadgerLogger struct {
	// contains filtered or unexported fields
}

func NewBadgerLogger

func NewBadgerLogger(log *zap.Logger) *BadgerLogger

func (*BadgerLogger) Debugf

func (l *BadgerLogger) Debugf(s string, i ...interface{})

func (*BadgerLogger) Errorf

func (l *BadgerLogger) Errorf(s string, i ...interface{})

func (*BadgerLogger) Infof

func (l *BadgerLogger) Infof(s string, i ...interface{})

func (*BadgerLogger) Warningf

func (l *BadgerLogger) Warningf(s string, i ...interface{})

type Config

type Config struct {
	Preset PresetEnum `yaml:"preset" env:"PRESET" env-default:"production"`

	Development PresetConfig `yaml:"development" env-prefix:"DEVELOPMENT_"`
	Production  PresetConfig `yaml:"production"  env-prefix:"PRODUCTION_"`
}

type OutputEnum

type OutputEnum int
const (
	OutputUnknown OutputEnum = iota // unknown
	OutputStdout  OutputEnum = iota // stdout
	OutputStderr  OutputEnum = iota // stderr
	OutputFile    OutputEnum = iota // file
)

func OutputFromString

func OutputFromString(value string) OutputEnum

func (OutputEnum) MarshalText

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

func (*OutputEnum) SetValue

func (e *OutputEnum) SetValue(value string) error

func (OutputEnum) String

func (i OutputEnum) String() string

func (*OutputEnum) UnmarshalText

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

type OutputFileConfig

type OutputFileConfig struct {
	Dir        string `yaml:"dir"        env:"DIR"         env-default:"logs"`
	TimeLayout string `yaml:"timeLayout" env:"TIME_LAYOUT" env-default:"2006-01-02"`
}

type OutputValueError

type OutputValueError struct {
	Value string
}

func (*OutputValueError) Error

func (e *OutputValueError) Error() string

type PresetConfig

type PresetConfig struct {
	Level             string              `yaml:"level"             env:"LEVEL"               env-default:""`
	EnableCaller      bool                `yaml:"enableCaller"      env:"ENABLE_CALLER"       env-default:"false"`
	DisableStacktrace bool                `yaml:"disableStacktrace" env:"DISABLE_STACKTRACE"  env-default:"false"`
	LevelEncoder      string              `yaml:"levelEncoder"      env:"LEVEL_ENCODER"       env-default:""`
	TimeEncoder       string              `yaml:"timeEncoder"       env:"TIME_ENCODER"        env-default:""`
	TimeLayout        string              `yaml:"timeLayout"        env:"TIME_LAYOUT"         env-default:""`
	DurationEncoder   string              `yaml:"durationEncoder"   env:"DURATION_ENCODER"    env-default:"string"`
	Outputs           map[OutputEnum]bool `yaml:"outputs"           env:"OUTPUTS"             env-default:""`
	OutputFile        OutputFileConfig    `yaml:"outputFile"        env-prefix:"OUTPUT_FILE_"`
}

type PresetEnum

type PresetEnum int
const (
	PresetUnknown     PresetEnum = iota // unknown
	PresetDevelopment PresetEnum = iota // development
	PresetProduction  PresetEnum = iota // production
)

func PresetFromString

func PresetFromString(value string) PresetEnum

func (PresetEnum) MarshalText

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

func (*PresetEnum) SetValue

func (e *PresetEnum) SetValue(value string) error

func (PresetEnum) String

func (i PresetEnum) String() string

func (*PresetEnum) UnmarshalText

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

type PresetValueError

type PresetValueError struct {
	Value string
}

func (*PresetValueError) Error

func (e *PresetValueError) Error() string

Jump to

Keyboard shortcuts

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