logger

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

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"
)

Available logger level

View Source
const (
	LogrusConsoleConfig = "LOGRUS_CONSOLE_CONFIG"
	LogrusFileConfig    = "LOGRUS_FILE_CONFIG"
	ZapConsoleConfig    = "ZAP_CONSOLE_CONFIG"
	ZapFileConfig       = "ZAP_FILE_CONFIG"
)
View Source
const (
	//InstanceZapLogger will be used to create Zap instance for the logger
	InstanceZapLogger int = iota
	//InstanceLogrusLogger will be used to create Logrus instance for the logger
	InstanceLogrusLogger
)

Available logger instance

Variables

This section is empty.

Functions

func Debugf

func Debugf(format string, args ...interface{})

func Errorf

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

func Fatalf

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

func GetLogger

func GetLogger() interface{}

func Infof

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

func NewLogger

func NewLogger(config Configuration, loggerInstance int) error

NewLogger returns an instance of logger provided

func Panicf

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

func Warnf

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

Types

type Configuration

type Configuration map[string]interface{}

Configuration stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default

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
	GetLogger() interface{}
}

Logger is the list of all available method for logger

func WithFields

func WithFields(keyValues Fields) Logger

type LogrusConsoleConfiguration

type LogrusConsoleConfiguration struct {
	Enable     bool
	JSONFormat bool
	Level      string
}

type LogrusFileConfiguration

type LogrusFileConfiguration struct {
	Enable     bool
	JSONFormat bool
	Level      string
	Path       string
	MaxSize    int // MB
	Compress   bool
	MaxAge     int // Days
	MaxBackups int // Maximum number of files
}

type ZapConsoleConfiguration

type ZapConsoleConfiguration struct {
	Enable     bool
	JSONFormat bool
	Level      string
}

type ZapFileConfiguration

type ZapFileConfiguration struct {
	Enable     bool
	JSONFormat bool
	Level      string
	Path       string
	MaxSize    int // MB
	Compress   bool
	MaxAge     int // Days
	MaxBackups int // Maximum number of files
}

Jump to

Keyboard shortcuts

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