logger

package
v0.0.0-...-e31961d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevelString = "debug"
	InfoLevelString  = "info"
	WarnLevelString  = "warn"
	ErrorLevelString = "error"
	FatalLevelString = "fatal"
)

Log level

View Source
const DefaultTimeFormat = time.RFC3339

DefaultTimeFormat of logger

Variables

This section is empty.

Functions

func CreateLogFile

func CreateLogFile(filename string) (*os.File, error)

CreateLogFile create a file and return io.Writer for file manipulation

func LevelToString

func LevelToString(l Level) string

LevelToString convert log level to readable string

Types

type Config

type Config struct {
	Level      Level
	LogFile    string
	TimeFormat string
	Caller     bool
	UseColor   bool
	UseJSON    bool
}

Config of logger

type KV

type KV map[string]interface{}

KV is a type for logging with more information this used by with function

type Level

type Level int

Level of log

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

list of log level

func StringToLevel

func StringToLevel(level string) Level

StringToLevel to set string to level

type Logger

type Logger interface {
	// this method is not concurrently safe to acess
	// preferable to create a new logger instead
	SetConfig(config *Config) error
	SetLevel(level Level) error
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugw(msg string, KV KV)
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infow(msg string, KV KV)
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warnw(msg string, KV KV)
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorw(msg string, KV KV)
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Fatalw(msg string, KV KV)
}

Logger interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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