Copyright © 2001, Chris Gonnerman
These modules define some interesting file-like objects:
This module provides a convenient file-like object (writing only)
which dates output lines automatically.
There is also a public function, logtime(), which returns the current
date in the format used by the LogFile class.
from Logger import LogFile
sys.stderr = LogFile(open("example.log", "a"))
This module implements a class, NWayOutput, which must be instantiated
with one or more file-like objects (capable of write). The file-like
objects may be given as a tuple, list, or as multiple arguments.
Assuming you have done this:
any call of nf.write() calls file1.write(), file2.write(), and file3.write()
with the given arguments.
nf = NWayOutput.NWayOutput(file1, file2, file3)
What's it good for? How about this:
As you can imagine, this is very handy combined with Logger.py.
from NWayOutput import NWayOutput
sys.stderr = \
NWayOutput(sys.stderr, open("logfile.txt", "w"))
This package includes a Distutils-based installer. Assuming you are running
Python 2.0 or higher or have installed the Distutils, you can just do this:
(as root/Adminstrator if necessary) and you're done.
python setup.py install
Alternately, just copy the included Logger.py and NWayOutput.py to your
site-packages directory or somewhere else in sys.path.