File: standard_logger.go

package info (click to toggle)
golang-github-nicholas-fedor-shoutrrr 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,432 kB
  • sloc: sh: 74; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 718 bytes parent folder | download
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
package standard

import (
	"github.com/nicholas-fedor/shoutrrr/pkg/types"
	"github.com/nicholas-fedor/shoutrrr/pkg/util"
)

// Logger provides the utility methods Log* that maps to Logger.Print*.
type Logger struct {
	logger types.StdLogger
}

// Logf maps to the service loggers Logger.Printf function.
func (sl *Logger) Logf(format string, v ...any) {
	sl.logger.Printf(format, v...)
}

// Log maps to the service loggers Logger.Print function.
func (sl *Logger) Log(v ...any) {
	sl.logger.Print(v...)
}

// SetLogger maps the specified logger to the Log* helper methods.
func (sl *Logger) SetLogger(logger types.StdLogger) {
	if logger == nil {
		sl.logger = util.DiscardLogger
	} else {
		sl.logger = logger
	}
}