1
4
mirror of https://github.com/yunginnanet/HellPot synced 2024-06-30 01:30:53 +00:00

Logging: implement trace level

This commit is contained in:
kayos@tcp.direct 2022-03-06 12:03:36 -08:00
parent dfaccefdd4
commit a04219477a
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
4 changed files with 15 additions and 4 deletions

@ -23,6 +23,10 @@ func argParse() {
printUsage() printUsage()
case "--genconfig": case "--genconfig":
GenConfig = true GenConfig = true
case "--debug", "-v",
forceDebug = true
case "--trace", "-vv",
forceTrace = true
case "--nocolor": case "--nocolor":
noColorForce = true noColorForce = true
case "--banner": case "--banner":

@ -25,8 +25,10 @@ var (
// exported generic vars // exported generic vars
var ( var (
// Debug is the value of our debug on/off toggle as per the current configuration. // Trace is the value of our trace (extra verbose) on/off toggle as per the current configuration.
Debug bool 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 returns the current location of our toml config file.
Filename string Filename string
) )
@ -142,6 +144,7 @@ func processOpts() {
boolOpt := map[string]*bool{ boolOpt := map[string]*bool{
"http.use_unix_socket": &UseUnixSocket, "http.use_unix_socket": &UseUnixSocket,
"logger.debug": &Debug, "logger.debug": &Debug,
"logger.trace": &Trace,
"performance.restrict_concurrency": &RestrictConcurrency, "performance.restrict_concurrency": &RestrictConcurrency,
"logger.nocolor": &NoColor, "logger.nocolor": &NoColor,
} }
@ -179,7 +182,10 @@ func associateExportedVariables() {
} }
} }
if Debug { if Debug || forceDebug {
zerolog.SetGlobalLevel(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel)
} }
if Trace || forceTrace {
zerolog.SetGlobalLevel(zerolog.TraceLevel)
}
} }

@ -15,6 +15,7 @@ var (
var defOpts = map[string]map[string]interface{}{ var defOpts = map[string]map[string]interface{}{
"logger": { "logger": {
"debug": true, "debug": true,
"trace": false,
"directory": deflogdir, "directory": deflogdir,
"nocolor": defNoColor, "nocolor": defNoColor,
"use_date_filename": true, "use_date_filename": true,

@ -44,7 +44,7 @@ func hellPot(ctx *fasthttp.RequestCtx) {
wn, err = heffalump.DefaultHeffalump.WriteHell(bw) wn, err = heffalump.DefaultHeffalump.WriteHell(bw)
n += wn n += wn
if err != nil { if err != nil {
slog.Debug().Err(err).Msg("END_ON_ERR") slog.Trace().Err(err).Msg("END_ON_ERR")
break break
} }
} }