logger

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 8 Imported by: 5

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

Constants

This section is empty.

Variables

View Source
var L *zap.Logger // Global Logger
View Source
var S *zap.SugaredLogger // Global Sugared Logger

Functions

func NewDevLogger

func NewDevLogger(outputs ...string) error

NewDevLogger creates a new Development logger.

func NewDevLoggerLevel

func NewDevLoggerLevel(lvl zapcore.Level, outputs ...string) error

NewDevLoggerLevel creates a Dev logger at the specified logging level.

func NewLoggerFromFile

func NewLoggerFromFile(filename string) error

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 NewProdLogger

func NewProdLogger(outputs ...string) error

NewProdLogger creates a new Production logger.

func NewProdLoggerLevel

func NewProdLoggerLevel(lvl zapcore.Level, outputs ...string) error

NewProdLoggerLevel creates a Prod logger at the specified logging level.

func NewSugaredDevLogger

func NewSugaredDevLogger() error

NewSugaredDevLogger creates a new Development Sugared logger.

func NewSugaredLoggerFromFile

func NewSugaredLoggerFromFile(filename string) error

NewSugaredLoggerFromFile created a sugared logger from the supplied JSON config file.

func NewSugaredProdLogger

func NewSugaredProdLogger(outputs ...string) error

NewSugaredProdLogger creates a new Production Sugared logger.

func NewSugaredProdLoggerLevel

func NewSugaredProdLoggerLevel(lvl zapcore.Level, outputs ...string) error

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

func SetupAppDynamicLogging(dynamicPort string, dynamicLogging bool)

SetupAppDynamicLogging enables dynamic app logging if requested.

func SetupAppLogger added in v0.1.0

func SetupAppLogger(appMode, configFile string, appDebug bool, logOutputs ...string) error

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.

func SyncZap

func SyncZap()

SyncZap flushes the buffered logs and captures any sync issues.

Types

This section is empty.

Jump to

Keyboard shortcuts

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