logstd

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package logstd contains utilities for standardizing logging across different apps at Fensak.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(c *Logger) *zap.Logger

GetLogger returns the zap logger object. This can be used to customize the logger object.

func GetSugaredLogger

func GetSugaredLogger(c *Logger) *zap.SugaredLogger

GetSugaredLogger returns the zap sugared logger which can be used to emit log messages from the app.

func GetSugaredLoggerWithoutConfig

func GetSugaredLoggerWithoutConfig() (*zap.SugaredLogger, error)

GetSugardLoggerWithoutConfig returns a generic zap sugared logger without configuration. This is useful for emitting log messages before the initialization stage.

func GetTestSugaredLogger

func GetTestSugaredLogger() *zap.SugaredLogger

GetTestLogger returns the zap sugared logger which can be used during testing.

func GetZapConfig

func GetZapConfig(lcfg *Logger) zap.Config

GetZapConfig returns the configuration for zap.

Types

type Logger

type Logger struct {
	Level       string   `mapstructure:"level"`
	OutputPaths []string `mapstructure:"outputpaths"`
	Encoding    string   `mapstructure:"encoding"`
	// contains filtered or unexported fields
}

Logger represents configuration options for the zap logger. If this is not set in the config, defaults to a logger optimized for production use. This can be embedded in a viper compatible config struct.

func NewLoggerCfgForTest

func NewLoggerCfgForTest() *Logger

NewLoggerCfgForTest returns a logging configuration that is optimized for use in a testing environment.

func (*Logger) AddHooks

func (lcfg *Logger) AddHooks(hooks ...func(zapcore.Entry) error)

func (*Logger) SetAtomicLevel

func (lcfg *Logger) SetAtomicLevel() error

Jump to

Keyboard shortcuts

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