log

package
v0.0.0-...-ed7e9db Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package log configures a new logger for an application.

Index

Constants

View Source
const (
	//Debug has verbose message
	Debug = "debug"
	//Info is default log level
	Info = "info"
	//Warn is for logging messages about possible issues
	Warn = "warn"
	//Error is for logging errors
	Error = "error"
	//Fatal is for logging fatal messages. The sytem shutsdown after logging the message.
	Fatal = "fatal"
)
View Source
const (
	// InstanceZapLogger indicates the logger type is zap
	InstanceZapLogger int = iota
	// InstanceLogrusLogger indicates the logger type is logrus
	InstanceLogrusLogger
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Format specifies the output log format.
	// Accepted values are: json, logfmt
	Format string

	// Level is the minimum log level that should appear on the output.
	Level string

	// NoColor makes sure that no log output gets colorized.
	NoColor bool

	// EnableFile saves logs to a file
	EnableFile bool

	// EnableConsole  actives console to print out logs
	EnableConsole bool

	// FileLocation is the path of log file
	FileLocation string
}

Config holds details necessary for logging.

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})

	Infof(format string, args ...interface{})

	Warnf(format string, args ...interface{})

	Errorf(format string, args ...interface{})

	Fatalf(format string, args ...interface{})

	Panicf(format string, args ...interface{})

	WithFields(keyValues Fields) Logger
}

Logger is our contract for the logger

func NewLogger

func NewLogger(config Config, loggerInstance int) (Logger, error)

NewLogger returns an instance of logger

Jump to

Keyboard shortcuts

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