logging

package
v0.0.0-...-947ddfb Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logging is a wrapper around Uber's zap logger, which has many configuration possibilities, so this package simplifies the instantiation of the logger. Services can still create their own zap logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...zap.Field)

func Error

func Error(msg string, fields ...zap.Field)

func Fatal

func Fatal(msg string, fields ...zap.Field)

func Info

func Info(msg string, fields ...zap.Field)

func SetGlobalLogger

func SetGlobalLogger(logger Logger)

SetGlobalLogger sets the global logger

func Warn

func Warn(msg string, fields ...zap.Field)

Types

type Logger

type Logger interface {
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Fatal(msg string, fields ...zap.Field)
}

func ConfigureLogger

func ConfigureLogger(loggerType LoggerType) (Logger, error)

ConfigureLogger takes in a logger type, and returns the logger for that environment. For tests, it returns a Nop logger. For development, it returns a logger that writes to the console in a human readable way, with caller and stack traces enabled for warn level errors. For production, it removes the callers and stack traces (except in Error level logs) in favor of speed/performance.

func GetGlobalLogger

func GetGlobalLogger() Logger

GetGlobalLogger returns the global logger

type LoggerType

type LoggerType string
const (
	DevLogger  LoggerType = "dev-logger"
	ProdLogger LoggerType = "prod-logger"
	TestLogger LoggerType = "test-logger"
)

Jump to

Keyboard shortcuts

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