File: global.go

package info (click to toggle)
golang-github-anacrolix-log 0.13.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 2
file content (41 lines) | stat: -rw-r--r-- 871 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
31
32
33
34
35
36
37
38
39
40
41
package log

import (
	"fmt"
	"io/ioutil"
	"os"
)

var (
	DefaultHandler = StreamHandler{
		W:   os.Stderr,
		Fmt: LineFormatter,
	}
	Default        Logger // Inited after GO_LOG is parsed.
	DiscardHandler = StreamHandler{
		W:   ioutil.Discard,
		Fmt: func(Record) []byte { return nil },
	}
)

func Levelf(level Level, format string, a ...interface{}) {
	Default.LazyLog(level, func() Msg {
		return Fmsg(format, a...).Skip(1)
	})
}

func Printf(format string, a ...interface{}) {
	Default.Log(Fmsg(format, a...).Skip(1))
}

// Prints the arguments to the Default Logger.
func Print(a ...interface{}) {
	// TODO: There's no "Print" equivalent constructor for a Msg, and I don't know what I'd call it.
	Str(fmt.Sprint(a...)).Skip(1).Log(Default)
}

func Println(a ...interface{}) {
	Default.LazyLogDefaultLevel(func() Msg {
		return Str(fmt.Sprintln(a...)).Skip(1)
	})
}