Improve error / console handling / output
fako1024 opened this issue · 2 comments
fako1024 commented
Right now error (and informational) logging to the console is a bit flaky. There's a few things to consider IMHO:
- Formatting: There's a few places where we differentiate between pretty-printing and non-pretty-printing, which is nice, but there's at least one place in
root.go
ofgoQuery
where we "force" pretty printing although we don't know if it's properly supported (plus, the way it's done feels a bit clumsy):
if err != nil {
return fmt.Errorf(`failed to execute query
Error: %w
Statement:
%s`, err, types.PrettyIndent(stmt, 4))
}
- Logging: It seems that logging is not fully set up as intended, there is an informational line in
DBWorkManager.go
that should trigger on cancellation, but doesn't (or at least it's not shown):
// query was cancelled, exit
logger.Infof("Query cancelled (workload %d / %d)...", w.nWorkloadsProcessed.Load(), w.nWorkloads)
- Case: I'm pretty sure there are still some log lines which use uppercase at the beginning of the line (while for errors and most informational output we use lowercase). Might make sense to review it all at once.
- Fix the indentation on the condition parsing
There may be more issues, but I think some form of refactoring (in particular adding a few helpers to make stuff easier) would help.
els0r commented
Something noticed when the infinite recursion error was fixed: now, the condition parsing error isn't aligned in a user-friendly way. As in: the cursor doesn't help anymore:
Error running query: failed to prepare query:
Field: condition
Message: invalid condition
Details: host 1.2.3.4
^
expected comparison operator
Should be:
Error running query: failed to prepare query:
Field: condition
Message: invalid condition
Details:
host 1.2.3.4
^
expected comparison operator
els0r commented
Logging: It seems that logging is not fully set up as intended, there is an informational line in DBWorkManager.go that should trigger on cancellation, but doesn't (or at least it's not shown)
The default level is Warn
, hence you don't see the info messages.