From ea5dc78faf348cd495f75840e9f21d672e68c5c7 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Thu, 13 Jul 2017 09:46:03 -0400 Subject: [PATCH] Use btclog for determining valid log levels. This allows levels to be specified by their shorthand versions (CRIT vs CRITICAL, for example), works with any capitalization, and adds support for handling the OFF level (previously the least verbose log level that could be set was CRITICAL). --- config.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/config.go b/config.go index eac2023032..b52955ed1a 100644 --- a/config.go +++ b/config.go @@ -21,6 +21,7 @@ import ( "strings" "time" + "github.com/btcsuite/btclog" flags "github.com/btcsuite/go-flags" "github.com/btcsuite/go-socks/socks" "github.com/decred/dcrd/connmgr" @@ -191,21 +192,8 @@ func cleanAndExpandPath(path string) string { // validLogLevel returns whether or not logLevel is a valid debug log level. func validLogLevel(logLevel string) bool { - switch logLevel { - case "trace": - fallthrough - case "debug": - fallthrough - case "info": - fallthrough - case "warn": - fallthrough - case "error": - fallthrough - case "critical": - return true - } - return false + _, ok := btclog.LevelFromString(logLevel) + return ok } // supportedSubsystems returns a sorted slice of the supported subsystems for