logger

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT, MIT Imports: 5 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

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func (*Config) OpenLogFile

func (c *Config) OpenLogFile() (*os.File, error)

OpenLogFile tries to open the log file (creates it if not exists) in write-only/append mode and return it Note: the func return nil for both *os.File and error if the file name is empty string

type Level

type Level int

Level of log

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

list of log level

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*Logger, error)

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug function

func (*Logger) DebugWithFields

func (l *Logger) DebugWithFields(msg string, kv map[string]interface{})

DebugWithFields function

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

Debugf function

func (*Logger) Debugln

func (l *Logger) Debugln(args ...interface{})

Debugln function

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error function

func (*Logger) ErrorWithFields

func (l *Logger) ErrorWithFields(msg string, kv map[string]interface{})

ErrorWithFields function

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

Errorf function

func (*Logger) Errorln

func (l *Logger) Errorln(args ...interface{})

Errorln function

func (*Logger) Errors

func (l *Logger) Errors(err error)

Errors function to log errors package

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal function

func (*Logger) FatalWithFields

func (l *Logger) FatalWithFields(msg string, kv map[string]interface{})

FatalWithFields function

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

Fatalf function

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...interface{})

Fatalln function

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info function

func (*Logger) InfoWithFields

func (l *Logger) InfoWithFields(msg string, kv map[string]interface{})

InfoWithFields function

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

Infof function

func (*Logger) Infoln

func (l *Logger) Infoln(args ...interface{})

Infoln function

func (*Logger) IsValid

func (l *Logger) IsValid() bool

IsValid check if Logger is created using constructor

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel for setting log level

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn function

func (*Logger) WarnWithFields

func (l *Logger) WarnWithFields(msg string, kv map[string]interface{})

WarnWithFields function

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...interface{})

Warnf function

func (*Logger) Warnln

func (l *Logger) Warnln(args ...interface{})

Warnln function

Jump to

Keyboard shortcuts

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