File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ package sphinx
2+
3+ import "github.com/btcsuite/btclog"
4+
5+ // sphxLog is a logger that is initialized with no output filters. This
6+ // means the package will not perform any logging by default until the caller
7+ // requests it.
8+ var sphxLog btclog.Logger
9+
10+ // The default amount of logging is none.
11+ func init () {
12+ DisableLog ()
13+ }
14+
15+ // DisableLog disables all library log output. Logging output is disabled
16+ // by default until UseLogger is called.
17+ func DisableLog () {
18+ sphxLog = btclog .Disabled
19+ }
20+
21+ // UseLogger uses a specified Logger to output package logging info.
22+ // This should be used in preference to SetLogWriter if the caller is also
23+ // using btclog.
24+ func UseLogger (logger btclog.Logger ) {
25+ sphxLog = logger
26+ }
27+
28+ // logClosure is used to provide a closure over expensive logging operations
29+ // so don't have to be performed when the logging level doesn't warrant it.
30+ type logClosure func () string
31+
32+ // String invokes the underlying function and returns the result.
33+ func (c logClosure ) String () string {
34+ return c ()
35+ }
36+
37+ // newLogClosure returns a new closure over a function that returns a string
38+ // which itself provides a Stringer interface so that it can be used with the
39+ // logging system.
40+ func newLogClosure (c func () string ) logClosure {
41+ return logClosure (c )
42+ }
You can’t perform that action at this time.
0 commit comments