logger

package
v0.0.0-...-b8d2545 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package logger provides functions to set up a new logger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(logger *Logger) func(next http.Handler) http.Handler

SetLogger returns a middleware that logs the start and end of each request, along with some useful data about what was requested, what the response status was, and how long it took to return. Inspired by https://github.com/treastech/logger func SetLogger(l *Logger, publisher publisher) func(next http.Handler) http.Handler {

Types

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

Logger is a small wrapper around a zap.Logger.

func New

func New(logLevel, logFormat string, logHttpRequest bool, cfg *config.LogPublisher) (*Logger, error)

New creates a new Logger with given logLevel and logFormat as part of a permanent field of the logger.

func (*Logger) Debug

func (logger *Logger) Debug(msg string, field ...zap.Field)

Debug wraps console message log in debug mode

func (*Logger) Error

func (logger *Logger) Error(msg string, field ...zap.Field)

Error wraps console message log in error level

func (*Logger) Info

func (logger *Logger) Info(msg string, field ...zap.Field)

Info wraps console message log in info level

func (*Logger) Notice

func (logger *Logger) Notice(msg string, field ...zap.Field)

Notice wraps console message log in info level

func (*Logger) Warn

func (logger *Logger) Warn(msg string, field ...zap.Field)

Warn wraps console message log in warn level

Jump to

Keyboard shortcuts

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