1
4
mirror of https://github.com/yunginnanet/HellPot synced 2024-06-27 08:18:03 +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()
case "--genconfig":
GenConfig = true
case "--debug", "-v",
forceDebug = true
case "--trace", "-vv",
forceTrace = true
case "--nocolor":
noColorForce = true
case "--banner":

@ -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)
}
}

@ -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,

@ -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
}
}