1#! /usr/bin/env python
2
3"""
4Provides a logger that prints regular messages and logger messages.
5Logged messages are typically written to a log file, while regular messages
6typically are printed to stdout
7"""
8
9import sys
10
11class Logger:
12
13    def __init__( self, message_fd, logfile_fd ):
14        self.message_fd = message_fd
15        self.logfile_fd = logfile_fd
16
17    def message( self, message ):
18        print >> self.message_fd, message
19
20    def log( self, message ):
21        print >> self.logfile_fd, message
22
23    def both( self, message ):
24        self.message( message )
25        self.log( message )
26
27
28
29if __name__ == '__main__':
30    print >> sys.stderr, "The python source file %s is a module and not runnable" % sys.argv[ 0 ]
31    sys.exit( 1 )
32