Documentation
¶
Index ¶
- Constants
- type Configurer
- type Log
- func (log *Log) Alert(a ...interface{})
- func (log *Log) Alertf(format string, a ...interface{})
- func (log *Log) Close()
- func (log *Log) Critical(a ...interface{})
- func (log *Log) Criticalf(format string, a ...interface{})
- func (log *Log) Debug(a ...interface{})
- func (log *Log) Debugf(format string, a ...interface{})
- func (log *Log) Emergency(a ...interface{})
- func (log *Log) Emergencyf(format string, a ...interface{})
- func (log *Log) Error(a ...interface{})
- func (log *Log) Errorf(format string, a ...interface{})
- func (log *Log) Info(a ...interface{})
- func (log *Log) Infof(format string, a ...interface{})
- func (log *Log) Notice(a ...interface{})
- func (log *Log) Noticef(format string, a ...interface{})
- func (log *Log) Warning(a ...interface{})
- func (log *Log) Warningf(format string, a ...interface{})
- type Logger
Constants ¶
View Source
const ( EMERGENCY int = iota // 0 ALERT // 1 CRITICAL // 2 ERROR // 3 WARNING // 4 NOTICE // 5 INFO // 6 DEBUG // 7 )
log level constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configurer ¶
type Configurer interface {
LogFile() string
LogLevel() int
LokiPushURL() string
LokiLabels() string // "{foo=\"bar\"}"
LokiBatchWait() time.Duration
LokiSendLevel() int
}
Configurer represents config object interface
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log struct represents application logger
func (*Log) Critical ¶ added in v1.1.0
func (log *Log) Critical(a ...interface{})
Critical wraps println
func (*Log) Emergency ¶ added in v1.1.0
func (log *Log) Emergency(a ...interface{})
Emergency wraps println
func (*Log) Emergencyf ¶
Emergencyf wraps formatted Error
type Logger ¶
type Logger interface {
Emergency(a ...interface{})
Emergencyf(format string, a ...interface{})
Alert(a ...interface{})
Alertf(format string, a ...interface{})
Critical(a ...interface{})
Criticalf(format string, a ...interface{})
Error(a ...interface{})
Errorf(format string, a ...interface{})
Warning(a ...interface{})
Warningf(format string, a ...interface{})
Notice(a ...interface{})
Noticef(format string, a ...interface{})
Info(a ...interface{})
Infof(format string, a ...interface{})
Debug(a ...interface{})
Debugf(format string, a ...interface{})
Close()
}
func New ¶ added in v1.1.0
func New(cfg Configurer) (Logger, error)
New constructor for application logger
Fields:
path - path to log file level - log level, possible levels: 0 - Emergency, with panic exit. 1 - Alert, with exit 2. 2 - Critical, with ext 1. 3 - Errors. 4 - Warnings. 5 - Notice. 6 - Info. 7 - Debug.
func main() {
// initialization application log system
var err error
logger := logger.Log{}
if logger, err = logger.NewLogger("/some/path", 0); err != nil {
panic(err)
}
}
Click to show internal directories.
Click to hide internal directories.