add conditional python-faulthandler support and log stderr even as a daemon
add conditional python-faulthandler support and log stderr even as a daemon

This patch does two things to enhance logging when debug mode is enabled.

It makes an attempt to setup up a python faulthanlder if the module is available.
This provides tracebacks on all running threads in the event of a segfault or other
process termination.  Details of faulthander are here:

http://pypi.python.org/pypi/faulthandler/

It also opens a real file to catch any ouput that happens to occur to stderr and
stdout while we are running.  Without this in place we are forced to run in the
foreground (and in a screen session or other externally log-able terminal) in order
to see stderr and stdout output.

Among other things, this allows us to capture debug output from libguestfs as well
as any stderr messages that the Python interpreter itself may output during a failure.

redhat-imaging/imagefactory,henrysher/imagefactory,redhat-imaging/imagefactory,henrysher/imagefactory,LalatenduMohanty/imagefactory,jmcabandara/imagefactory,LalatenduMohanty/imagefactory,jmcabandara/imagefactory