Closed tmm1 closed 1 year ago
It would be nice to be able to vary log level programatically
For example the same message in some cases might be debug, but in other cases a warning.
if rejectFailure { log.Error("Request NOK", "url", url, "status", status, "query", query) } else { log.Debug("Request NOK", "url", url, "status", status, "query", query) }
vs
log.Log(lo.If(rejectFailure, log.ErrorLevel).Else(log.DebugLevel), "Request NOK", ...)
I guess now that I think about it, an alternative already possible is to vary the function pointer..
lo.If(rejectFailure, log.Error).Else(log.Debug)("Request NOK", ...)
You could use function variables:
logger := log.Debug if rejectFailure { logger = log.Error } logger("Request NOK", "url", url, ...)
It would be nice to be able to vary log level programatically
For example the same message in some cases might be debug, but in other cases a warning.
vs
I guess now that I think about it, an alternative already possible is to vary the function pointer..