grnet/synnefo — pull request #25 by iliastsi (2014-03-17 11:48:36+00:00)
Title: Logging mechanism for Synnefo management commands

All Synnefo's management commands are written as custom django-admin commands.
This means that every management command is in fact a class that extends
Django's BaseCommand class.

Django's *BaseCommand* provides the attributes ``self.stdout`` and
``self.stderr`` and Django's documentation encourages the users to use these
attributes if they wish to write to the console. Django doesn't provide an
option to write the output to files and the user has to implement this
explicitly when implementing the ``handle`` method.

We would like to extend the above mechanism to allow every ``snf-manage``
command to log all stdout and stderr output on a unique filename under a given
directory. The implementation should change nothing in the way that users write
management commands (only acceptable change is that the new commands may have
to inherit a new class and not the *BaseCommand* one). This means that
existing management commands should play out of the box and also that the
logging mechanism will globally apply to all of them.

Commands that do not alter the state of the server (i.e. \*-list and \*-show
commands) will be excluded from the logging mechanism.