log.go
 1  // Copyright (c) 2013-2016 The btcsuite developers
 2  // Use of this source code is governed by an ISC
 3  // license that can be found in the LICENSE file.
 4  
 5  package database
 6  
 7  import (
 8  	"github.com/btcsuite/btclog"
 9  )
10  
11  // log is a logger that is initialized with no output filters.  This
12  // means the package will not perform any logging by default until the caller
13  // requests it.
14  var log btclog.Logger
15  
16  // The default amount of logging is none.
17  func init() {
18  	DisableLog()
19  }
20  
21  // DisableLog disables all library log output.  Logging output is disabled
22  // by default until UseLogger is called.
23  func DisableLog() {
24  	log = btclog.Disabled
25  }
26  
27  // UseLogger uses a specified Logger to output package logging info.
28  func UseLogger(logger btclog.Logger) {
29  	log = logger
30  
31  	// Update the logger for the registered drivers.
32  	for _, drv := range drivers {
33  		if drv.UseLogger != nil {
34  			drv.UseLogger(logger)
35  		}
36  	}
37  }