Changeset 17:83107382582b in livinglogic.python.tipimaid

Show
Ignore:
Timestamp:
11/24/08 14:45:40 (10 years ago)
Author:
Nikolas Tautenhahn <nik@…>
Branch:
default
Message:

added .debug; if set to True all loglines are written to a debuglog. self.debug might be switched by HUP-Signal for example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • liaalh.py

    r16 r17  
    1212 
    1313class Buffer(object): 
    14     def __init__(self, pattern='', gzip_logs=None, buffertime=5, stream=sys.stdin): 
     14    def __init__(self, pattern='', gzip_logs=None, buffertime=5, stream=sys.stdin, debug=False): 
    1515        self.pattern = pattern 
    1616        self.gzip_logs = gzip_logs 
     
    2222        if gzip_logs is not None and not pattern.endswith(".gz"): 
    2323            self.pattern = "%s.gz" % self.pattern 
     24        self.debug = debug 
    2425 
    2526    def add(self, logline): 
     27        if self.debug: 
     28            debugfile = open("/tmp/liaalh_debug.log", "a") 
     29            debugfile.write("%s: %r\n" % (datetime.datetime.now().isoformat(), logline)) 
     30            debugfile.close() 
    2631        if not self.data or logline > self.data[-1]: 
    2732            self.data.append(logline)