Documentation ¶
Overview ¶
Package logger simplifies the setup of a zap logger. It provides helpers for creating Dev & Prod loggers, including setting a logging level. These loggers are stored in package level global variables to aid calling them from other packages. There is also support for Atomic Levels, which enables the modification of a logging level while the system is running.
Index ¶
- Variables
- func NewDevLogger() error
- func NewDevLoggerLevel(lvl zapcore.Level) error
- func NewLoggerFromFile(filename string) error
- func NewProdLogger() error
- func NewProdLoggerLevel(lvl zapcore.Level) error
- func NewSugaredDevLogger() error
- func NewSugaredLoggerFromFile(filename string) error
- func NewSugaredProdLogger() error
- func NewSugaredProdLoggerLevel(lvl zapcore.Level) error
- func SetLevel(level string)
- func SetupAppDynamicLogging(dynamicPort string, dynamicLogging bool)
- func SetupAppLogger(appMode, configFile string, appDebug bool) error
- func SetupDynamicLogging(addr string)
- func SyncZap()
Constants ¶
This section is empty.
Variables ¶
var L *zap.Logger // Global Logger
var S *zap.SugaredLogger // Global Sugared Logger
Functions ¶
func NewDevLoggerLevel ¶
NewDevLoggerLevel creates a Dev logger at the specified logging level.
func NewLoggerFromFile ¶
NewLoggerFromFile created a logger from the supplied JSON config file Details for the fields can be found here: https://github.com/uber-go/zap/blob/master/config.go
func NewProdLoggerLevel ¶
NewProdLoggerLevel creates a Prod logger at the specified logging level.
func NewSugaredDevLogger ¶
func NewSugaredDevLogger() error
NewSugaredDevLogger creates a new Development Sugared logger.
func NewSugaredLoggerFromFile ¶
NewSugaredLoggerFromFile created a sugared logger from the supplied JSON config file.
func NewSugaredProdLogger ¶
func NewSugaredProdLogger() error
NewSugaredProdLogger creates a new Production Sugared logger.
func NewSugaredProdLoggerLevel ¶
NewSugaredProdLoggerLevel creates a new Production Sugared logger at the specified logging level.
func SetLevel ¶
func SetLevel(level string)
SetLevel enables the setting of the logging level while the system is still running.
func SetupAppDynamicLogging ¶ added in v0.1.0
SetupAppDynamicLogging enables dynamic app logging if requested.
func SetupAppLogger ¶ added in v0.1.0
SetupAppLogger creates a zap logger based on the application configuration options.
func SetupDynamicLogging ¶
func SetupDynamicLogging(addr string)
SetupDynamicLogging enables the ability to modify logging levels on the fly Details on how to call the endpoint can be found here: https://pkg.go.dev/go.uber.org/zap#section-readme To get debug status run: curl -X GET localhost:1065/log/level To set debug status run: curl -X PUT localhost:1065/log/level -d level=debug.
Types ¶
This section is empty.