Goal
Today I want to address some long-standing, but fairly minor issues in the Obnam project.
Plan
- Add some logging and remove debug prints. This requires picking a logging
system. That's a decision that can be changed later, so I'm going pick
logandenv_logger. It's possible we'll wanttracinglater, for structured logs if nothing else, but I want to start small. - The
obnam.orgweb site needs updating. As part of that, the subplot and architecture documents should be rendered as HTML and published by CI on thedoc.obnam.orgsite.
I might do more, if I have time.
Notes
Preparation
- Run
maketo ensure everything is still OK. It is.
Logging
- Create branch
logging. cargo add logcargo add env_loggermake- Commit changes.
- I need a systematic approach to how logging is used.
traceis for debug information aimed at Obnam developers- everything else is aimed at those running Obnam
debugis for detailed information aimed at troubleshootinginfois for high-level "what's happening" informationwarnis for things that aren't wrong, but should be looked at, and for non-fatal errorserroris for fatal errors
- At least for now I'll use the
logmacros directly. I may some day want to have wrappers around them, but for now I'll keep things simple. I like simple. - Add set up of
env_loggerinsrc/bin/obnam.rs. The default log level isinfo, and can be set with theOBNAM_LOGenvironment variable or the--log-levelglobal option. To test this, I'll makeobnamlog messages at all log levels at start up. - I'm not adding setting of configuration level to the configuration file, for now. It'll be an easy addition if someone actually needs it.
- After this, I merely need to add logging everywhere it's needed. However, I'm not making these acceptance criteria, that'd be way too much work for how important these are.
- From some quick grepping, there doesn't seem to be any debug printing in the code base any more. Good.
- Error messages in
mainshould be error logs. - I'll add a "subcommand invoked" debug message to every subcommand. I don't to just do a debug-formatted dump of the subcommand, I want to make the log message more useful.
- Today I'm not adding any
tracemessages, and only do a little to make thedebuglogging useful. Tweaking log messages is going to continue forever. - Committed changes, pushed to Radicle patch, failed.
- Ran
rad cito emulate CI locally. I should do this more diligently. - Hm, the log level scenario fails in CI, but works on my laptop.
- Oh, no it doesn't. CI runs more tests than
makedoes. Oops. - My logic for deteremining what log level to use is just broken. I'd use
clapto set a default value forobnam --log-levelthat overrides the environment variable. - Fixed that. CI now runs successfully.
- Merged.
All this debugging took long enough that I ran out of time, again. Bummer. I'll do the document publishing some later time.
Summary
Comments?
If you have feedback on this development session, please use the following fediverse thread: https://toot.liw.fi/@liw/115320733479998146.