Ejemplo n.º 1
0
// 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)
}
Ejemplo n.º 2
0
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)
}
Ejemplo n.º 3
0
Archivo: log.go Proyecto: Roasbeef/btcd
// 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
}