summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/go-hclog/global.go
blob: 55ce4396034e63984b77c2ea452c54e96e77d225 (plain)
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
package hclog

import (
	"sync"
)

var (
	protect sync.Once
	def     Logger

	// The options used to create the Default logger. These are
	// read only when the Default logger is created, so set them
	// as soon as the process starts.
	DefaultOptions = &LoggerOptions{
		Level:  DefaultLevel,
		Output: DefaultOutput,
	}
)

// Return a logger that is held globally. This can be a good starting
// place, and then you can use .With() and .Name() to create sub-loggers
// to be used in more specific contexts.
func Default() Logger {
	protect.Do(func() {
		def = New(DefaultOptions)
	})

	return def
}

// A short alias for Default()
func L() Logger {
	return Default()
}