/
journald_logger.go
46 lines (35 loc) · 1.09 KB
/
journald_logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//go:build !window
// +build !window
// Package journal implements the journal logger.
//
// RU:
// Package journald реализует логгер journald.
package journald
import (
"fmt"
log "github.com/ovsinc/multilog/common"
pkgjournal "github.com/coreos/go-systemd/journal"
)
// New constructor of the custom journald logger.
//
// RU:
// New конструктор journald логгера.
func New() log.Logger {
return &journaldlogger{}
}
type journaldlogger struct{}
func (l *journaldlogger) log(pri pkgjournal.Priority, format string, args ...interface{}) {
_ = pkgjournal.Send(fmt.Sprintf(format, args...), pri, nil)
}
func (l *journaldlogger) Debugf(format string, args ...interface{}) {
l.log(pkgjournal.PriDebug, format, args...)
}
func (l *journaldlogger) Infof(format string, args ...interface{}) {
l.log(pkgjournal.PriInfo, format, args...)
}
func (l *journaldlogger) Warnf(format string, args ...interface{}) {
l.log(pkgjournal.PriWarning, format, args...)
}
func (l *journaldlogger) Errorf(format string, args ...interface{}) {
l.log(pkgjournal.PriErr, format, args...)
}