File: writer.go

package info (click to toggle)
golang-github-spiffe-go-spiffe 2.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,116 kB
  • sloc: makefile: 157
file content (31 lines) | stat: -rw-r--r-- 684 bytes parent folder | download | duplicates (2)
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
package logger

import (
	"fmt"
	"io"
)

// Writer provides a logger that outputs logging to the given writer.
func Writer(w io.Writer) Logger {
	return writer{Writer: w}
}

type writer struct {
	io.Writer
}

func (w writer) Debugf(format string, args ...interface{}) {
	fmt.Fprintf(w.Writer, "[DEBUG] "+format+"\n", args...)
}

func (w writer) Infof(format string, args ...interface{}) {
	fmt.Fprintf(w.Writer, "[INFO] "+format+"\n", args...)
}

func (w writer) Warnf(format string, args ...interface{}) {
	fmt.Fprintf(w.Writer, "[WARN] "+format+"\n", args...)
}

func (w writer) Errorf(format string, args ...interface{}) {
	fmt.Fprintf(w.Writer, "[ERROR] "+format+"\n", args...)
}