fix: ensure all backends implement Backend

This commit is contained in:
Bruno Carlin 2022-06-03 10:20:07 +02:00
parent db53d11d61
commit 13cf00aba7
2 changed files with 7 additions and 1 deletions

View file

@ -22,6 +22,8 @@ type Backend interface {
// Backend to write in file-like objects // Backend to write in file-like objects
// //
var _ Backend = &FileBackend{}
// FileBackend is a backend that writes to a file. // FileBackend is a backend that writes to a file.
type FileBackend struct { type FileBackend struct {
formatter Formatter formatter Formatter
@ -130,6 +132,8 @@ func (b *FileBackend) Close() error {
// Noop Backend // Noop Backend
// //
var _ Backend = &NoopBackend{}
// NoopBackend does nothing and discards all log entries without writing them anywhere. // NoopBackend does nothing and discards all log entries without writing them anywhere.
type NoopBackend struct{} type NoopBackend struct{}
@ -144,7 +148,7 @@ func (*NoopBackend) Write(_ *Record) error {
} }
// SetFormatter is a noop. // SetFormatter is a noop.
func (*NoopBackend) SetFormatter(_ *Formatter) {} func (*NoopBackend) SetFormatter(_ Formatter) {}
// SetLevel is a noop. // SetLevel is a noop.
func (*NoopBackend) SetLevel(_ Level) {} func (*NoopBackend) SetLevel(_ Level) {}

View file

@ -16,6 +16,8 @@ var errUnknownFacility = errors.New("unknown facility")
// Syslog Backend // Syslog Backend
// //
var _ Backend = &SyslogBackend{}
// SyslogBackend writes the logs to a syslog system. // SyslogBackend writes the logs to a syslog system.
type SyslogBackend struct { type SyslogBackend struct {
w *syslog.Writer w *syslog.Writer