1# Copyright Pedro Ferreira 2005. Distributed under the Boost 2# Software License, Version 1.0. (See accompanying 3# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 5import sys 6 7class NullLogger: 8 def __init__ (self): 9 self.indent_ = '' 10 11 def log (self, source_name, *args): 12 if self.on () and self.interesting (source_name): 13 self.do_log (self.indent_) 14 for i in args: 15 self.do_log (i) 16 self.do_log ('\n') 17 18 def increase_indent (self): 19 if self.on (): 20 self.indent_ += ' ' 21 22 def decrease_indent (self): 23 if self.on () and len (self.indent_) > 4: 24 self.indent_ = self.indent_ [-4:] 25 26 def do_log (self, *args): 27 pass 28 29 def interesting (self, source_name): 30 return False 31 32 def on (self): 33 return True 34 35class TextLogger (NullLogger): 36 def __init__ (self): 37 NullLogger.__init__ (self) 38 39 def do_log (self, arg): 40 sys.stdout.write (str (arg)) 41 42 def interesting (self, source_name): 43 return True 44 45 def on (self): 46 return True 47