oVirt/vdsm

vdsm-tool: move logs from stdout print to logging

aesteve-rh opened this issue · 0 comments

Currently, vdsm-tool logs messages directly to the stdout using the sys module. However, this solution is very limiting:

  • Don't have severity levels, which limit control over what messages are printed, and make the programmer responsible for manually adding the severity in the message.
  • Don't have unified formatter. Messages can have inconsistent formats and lack information.
  • Messages are always printed from the vdsm-tool modules. For parts where the vdsm-tool acts as a wrapper for another vdsm module, any internal logging the vdsm module might do must be deferred to the vdsm-tool. Alternatively, with logging we can pass the object as a parameter to allow other modules to log messages directly to the vdsm-tool output, with consistent formatting.

Proposal

Use logging, instantiate it in the __init__ module and set up a format. From there we can import it in all submodules and use it instead of sys.stdout, with the proper severity level, and give it as parameter in wrapper modules.