1 // Copyright © 2016 Steve Francia <spf@spf13.com>.
3 // Use of this source code is governed by an MIT-style
4 // license that can be found in the LICENSE file.
6 package jwalterweatherman
27 defaultNotepad *Notepad
30 func reloadDefaultNotepad() {
31 TRACE = defaultNotepad.TRACE
32 DEBUG = defaultNotepad.DEBUG
33 INFO = defaultNotepad.INFO
34 WARN = defaultNotepad.WARN
35 ERROR = defaultNotepad.ERROR
36 CRITICAL = defaultNotepad.CRITICAL
37 FATAL = defaultNotepad.FATAL
39 LOG = defaultNotepad.LOG
40 FEEDBACK = defaultNotepad.FEEDBACK
44 defaultNotepad = NewNotepad(LevelError, LevelWarn, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
45 reloadDefaultNotepad()
48 // SetLogThreshold set the log threshold for the default notepad. Trace by default.
49 func SetLogThreshold(threshold Threshold) {
50 defaultNotepad.SetLogThreshold(threshold)
51 reloadDefaultNotepad()
54 // SetLogOutput set the log output for the default notepad. Discarded by default.
55 func SetLogOutput(handle io.Writer) {
56 defaultNotepad.SetLogOutput(handle)
57 reloadDefaultNotepad()
60 // SetStdoutThreshold set the standard output threshold for the default notepad.
62 func SetStdoutThreshold(threshold Threshold) {
63 defaultNotepad.SetStdoutThreshold(threshold)
64 reloadDefaultNotepad()
67 // SetPrefix set the prefix for the default logger. Empty by default.
68 func SetPrefix(prefix string) {
69 defaultNotepad.SetPrefix(prefix)
70 reloadDefaultNotepad()
73 // SetFlags set the flags for the default logger. "log.Ldate | log.Ltime" by default.
74 func SetFlags(flags int) {
75 defaultNotepad.SetFlags(flags)
76 reloadDefaultNotepad()
79 // Level returns the current global log threshold.
80 func LogThreshold() Threshold {
81 return defaultNotepad.logThreshold
84 // Level returns the current global output threshold.
85 func StdoutThreshold() Threshold {
86 return defaultNotepad.stdoutThreshold
89 // GetStdoutThreshold returns the defined Treshold for the log logger.
90 func GetLogThreshold() Threshold {
91 return defaultNotepad.GetLogThreshold()
94 // GetStdoutThreshold returns the Treshold for the stdout logger.
95 func GetStdoutThreshold() Threshold {
96 return defaultNotepad.GetStdoutThreshold()
99 // LogCountForLevel returns the number of log invocations for a given threshold.
100 func LogCountForLevel(l Threshold) uint64 {
101 return defaultNotepad.LogCountForLevel(l)
104 // LogCountForLevelsGreaterThanorEqualTo returns the number of log invocations
105 // greater than or equal to a given threshold.
106 func LogCountForLevelsGreaterThanorEqualTo(threshold Threshold) uint64 {
107 return defaultNotepad.LogCountForLevelsGreaterThanorEqualTo(threshold)
110 // ResetLogCounters resets the invocation counters for all levels.
111 func ResetLogCounters() {
112 defaultNotepad.ResetLogCounters()