Skip to content

Add (structured) logging

Johan Ouwerkerk requested to merge ouwerkerk/otpclient:logging into master

This MR is an 80/20 effort to fix the (many) TODO items about logging, covering the C++ code.

Nearly all TODO items are replaced with a log statement. I used the following logic:

levels

  • Warning for things that are meaningful and fixable by an end-user. E.g.: clipboard not available, storage not writable.
  • Info for life-cycle things that are meaningful to a user. E.g.: account was found in storage.
  • Debug for things that should have been caught by higher level validation/application logic. E.g.: output buffer too small for decoding base32 secret.
  • Debug for things that indicate consistency errors (assumption UI will also do something sane here). E.g.: invalid account details found in account storage.
  • Debug for life-cycle things that are not meaningful to a user. E.g.: jobs being dispatched on the worker thread, disposal of account storage.

what is logged

  • The conditions from the TODO items are converted to log statements
  • A few additional logging statements are added to better be able to follow the general lifecycle/flow of the application. This is meant to provide hints when a bug is spotted: the previous logging should give a fairly clear indication of "how far" the application/account got.
  • Assumption is that we should be generally avoid logging parameters/other metadata. E.g. never log input strings in the base32 module because these are likely account secrets (even if invalid).

Merge request reports