github.com/defanghe/fabric@v2.1.1+incompatible/idemix/logging.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package idemix 8 9 import "log" 10 11 // logger is used to log debug information. 12 var logger Logger = LogFunc(log.Printf) 13 14 // SetLogger sets the logger instance used for debug and error reporting. The 15 // logger reference is not mutex-protected so this must be set before calling 16 // any other library functions. 17 // 18 // If a custom logger is not defined, the global logger from the standard 19 // library's log package is used. 20 func SetLogger(l Logger) { 21 logger = l 22 } 23 24 // Logger defines the contract for logging. This interface is explicitly 25 // defined to be compatible with the logger in the standard library log 26 // package. 27 type Logger interface { 28 Printf(format string, a ...interface{}) 29 } 30 31 // LogFunc is a function adapter for logging. 32 type LogFunc func(format string, a ...interface{}) 33 34 // Printf is used to create a formatted string log record. 35 func (l LogFunc) Printf(format string, a ...interface{}) { 36 l(format, a...) 37 }