本文整理匯總了Golang中github.com/btcsuite/btclog.NewLoggerFromWriter函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewLoggerFromWriter函數的具體用法?Golang NewLoggerFromWriter怎麽用?Golang NewLoggerFromWriter使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewLoggerFromWriter函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestUseLogger
// TestUseLogger tests that a logger can be passed to UseLogger
func TestUseLogger(t *testing.T) {
l, err := btclog.NewLoggerFromWriter(bytes.NewBuffer(nil), btclog.InfoLvl)
if err != nil {
t.Fatal(err)
}
UseLogger(l)
}
示例2: init
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
// Enable logging (Debug level) to aid debugging failing tests.
logger, err := btclog.NewLoggerFromWriter(os.Stdout, btclog.DebugLvl)
if err != nil {
fmt.Printf("Failed to initialize stdout logger: %v\n", err)
os.Exit(1)
}
UseLogger(logger)
}
示例3: SetLogWriter
// SetLogWriter uses a specified io.Writer to output package logging info.
// This allows a caller to direct package logging output without needing a
// dependency on seelog. If the caller is also using btclog, UseLogger should
// be used instead.
func SetLogWriter(w io.Writer, level string) error {
if w == nil {
return errors.New("nil writer")
}
lvl, ok := btclog.LogLevelFromString(level)
if !ok {
return errors.New("invalid log level")
}
l, err := btclog.NewLoggerFromWriter(w, lvl)
if err != nil {
return err
}
UseLogger(l)
return nil
}