1// Copyright (c) 2013-2015 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 5package txscript 6 7import ( 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. 14var log btclog.Logger 15 16// The default amount of logging is none. 17func init() { 18 DisableLog() 19} 20 21// DisableLog disables all library log output. Logging output is disabled 22// by default until UseLogger is called. 23func DisableLog() { 24 log = btclog.Disabled 25} 26 27// UseLogger uses a specified Logger to output package logging info. 28func UseLogger(logger btclog.Logger) { 29 log = logger 30} 31 32// LogClosure is a closure that can be printed with %v to be used to 33// generate expensive-to-create data for a detailed log level and avoid doing 34// the work if the data isn't printed. 35type logClosure func() string 36 37func (c logClosure) String() string { 38 return c() 39} 40 41func newLogClosure(c func() string) logClosure { 42 return logClosure(c) 43} 44