logging

package module
v0.0.0-...-0f38422 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 1 Imported by: 2

README

logging

logging is a Golang library that defines a very simple logger interface conforming with logging best practices and Clean Architecture. It's especially useful as a standardized logger for microservices and libraries.

The logger has 4 levels:

  • Debug
  • Info
  • Warn
  • Error

All levels have 3 types of functions:

  • Simple — analogous to log.Print
  • According to a format — analogous to log.Printf
  • With key-value pairs

It's compatible with zap out of the box. If you want to use this interface with another logger you can make a wraper for it that implements Logger.

Installation

go get -u github.com/happybydefault/logging

More information

Documentation

Overview

Package logging defines a very simple logger interface conforming with logging best practices and Clean Architecture. It's especially useful as a standardized logger for microservices and libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Named

func Named(name string, logger Logger) named

Types

type Logger

type Logger interface {
	Debug(v ...interface{})
	Info(v ...interface{})
	Warn(v ...interface{})
	Error(v ...interface{})

	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Errorf(format string, v ...interface{})

	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
}

Logger defines a logger with 4 levels: Debug, Info, Warn and Error. All of them have 3 types of functions: simple, according to a format and with key-value pairs.

type Noop

type Noop struct{}

Noop is a no-op implementation of the logger interface. You can use it if you don't want to log at all.

func (Noop) Debug

func (n Noop) Debug(...interface{})

func (Noop) Debugf

func (n Noop) Debugf(string, ...interface{})

func (Noop) Debugw

func (n Noop) Debugw(string, ...interface{})

func (Noop) Error

func (n Noop) Error(...interface{})

func (Noop) Errorf

func (n Noop) Errorf(string, ...interface{})

func (Noop) Errorw

func (n Noop) Errorw(string, ...interface{})

func (Noop) Info

func (n Noop) Info(...interface{})

func (Noop) Infof

func (n Noop) Infof(string, ...interface{})

func (Noop) Infow

func (n Noop) Infow(string, ...interface{})

func (Noop) Warn

func (n Noop) Warn(...interface{})

func (Noop) Warnf

func (n Noop) Warnf(string, ...interface{})

func (Noop) Warnw

func (n Noop) Warnw(string, ...interface{})

Jump to

Keyboard shortcuts

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