Ejemplo n.º 1
0
// This is basically the same code as in tendermint. Initialize root
// and maybe later also track the loggers here.
func InitLogger(config *ServerConfig) {

	consoleLogLevel := config.Logging.ConsoleLogLevel

	// stdout handler
	handlers := []log15.Handler{}
	stdoutHandler := log15.LvlFilterHandler(
		getLevel(consoleLogLevel),
		log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
	)
	handlers = append(handlers, stdoutHandler)

	if config.Logging.LogFile != "" {
		fileLogLevel := config.Logging.FileLogLevel
		fh, err := log15.FileHandler(config.Logging.LogFile, log15.LogfmtFormat())
		if err != nil {
			fmt.Println("Error creating log file: " + err.Error())
			os.Exit(1)
		}
		fileHandler := log15.LvlFilterHandler(getLevel(fileLogLevel), fh)
		handlers = append(handlers, fileHandler)
	}

	rootHandler = log15.MultiHandler(handlers...)

	// By setting handlers on the root, we handle events from all loggers.
	log15.Root().SetHandler(rootHandler)
}
Ejemplo n.º 2
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	log15.Root().SetHandler(log15.LvlFilterHandler(
		log15.LvlWarn,
		log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
	))
	gin.SetMode(gin.ReleaseMode)
}
Ejemplo n.º 3
0
// You might want to call this after resetting tendermint/config.
func Reset() {

	var logLevel string = "debug"
	if config != nil {
		logLevel = config.GetString("log_level")
	}

	// stdout handler
	//handlers := []log15.Handler{}
	stdoutHandler := log15.LvlFilterHandler(
		getLevel(logLevel),
		log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
	)
	//handlers = append(handlers, stdoutHandler)

	// Set rootHandler.
	//rootHandler = log15.MultiHandler(handlers...)
	rootHandler = stdoutHandler

	// By setting handlers on the root, we handle events from all loggers.
	log15.Root().SetHandler(rootHandler)
}
Ejemplo n.º 4
0
func New(ctx ...interface{}) log15.Logger {
	return log15.Root().New(ctx...)
}