From af1e3f103a9df4755c59dc72abb4842c851fde9b Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Sun, 6 Mar 2022 12:03:36 -0800 Subject: [PATCH] Logging: implement trace level --- config/arguments.go | 4 ++++ config/config.go | 12 +++++++++--- config/defaults.go | 1 + http/router.go | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config/arguments.go b/config/arguments.go index 65b07db..45e2a6d 100644 --- a/config/arguments.go +++ b/config/arguments.go @@ -23,6 +23,10 @@ func argParse() { printUsage() case "--genconfig": GenConfig = true + case "--debug", "-v", + forceDebug = true + case "--trace", "-vv", + forceTrace = true case "--nocolor": noColorForce = true case "--banner": diff --git a/config/config.go b/config/config.go index 90bfbf9..aeff277 100644 --- a/config/config.go +++ b/config/config.go @@ -25,8 +25,10 @@ var ( // exported generic vars var ( - // Debug is the value of our debug on/off toggle as per the current configuration. - Debug bool + // Trace is the value of our trace (extra verbose) on/off toggle as per the current configuration. + Trace bool + // Debug is the value of our debug (verbose) on/off toggle as per the current configuration. + Debug bool // Filename returns the current location of our toml config file. Filename string ) @@ -142,6 +144,7 @@ func processOpts() { boolOpt := map[string]*bool{ "http.use_unix_socket": &UseUnixSocket, "logger.debug": &Debug, + "logger.trace": &Trace, "performance.restrict_concurrency": &RestrictConcurrency, "logger.nocolor": &NoColor, } @@ -179,7 +182,10 @@ func associateExportedVariables() { } } - if Debug { + if Debug || forceDebug { zerolog.SetGlobalLevel(zerolog.DebugLevel) } + if Trace || forceTrace { + zerolog.SetGlobalLevel(zerolog.TraceLevel) + } } diff --git a/config/defaults.go b/config/defaults.go index 809c0f9..ad4a2b2 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -15,6 +15,7 @@ var ( var defOpts = map[string]map[string]interface{}{ "logger": { "debug": true, + "trace": false, "directory": deflogdir, "nocolor": defNoColor, "use_date_filename": true, diff --git a/http/router.go b/http/router.go index eec6063..e360bda 100644 --- a/http/router.go +++ b/http/router.go @@ -44,7 +44,7 @@ func hellPot(ctx *fasthttp.RequestCtx) { wn, err = heffalump.DefaultHeffalump.WriteHell(bw) n += wn if err != nil { - slog.Debug().Err(err).Msg("END_ON_ERR") + slog.Trace().Err(err).Msg("END_ON_ERR") break } }