Project

General

Profile

Revision 675

A few minor changes so Haizea will work with Python 2.4

View differences:

log.py
17 17
# -------------------------------------------------------------------------- #
18 18

  
19 19
import logging
20
import sys
20 21
from haizea.common.utils import get_clock
21 22
from haizea.common.constants import LOGLEVEL_VDEBUG, LOGLEVEL_STATUS
22 23

  
......
26 27
# Custom logger that uses our log record
27 28
class HaizeaLogger(logging.Logger):
28 29
    
29
    def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info, func, extra):
30
    def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None):
30 31
        # Modify "extra" parameter keyword
31 32
        try:
32 33
            haizeatime = get_clock().get_time()
33
            extra = { "haizeatime" : haizeatime}
34 34
        except:
35 35
            # This is a kludge. Basically, calling get_clock will
36 36
            # fail if Manager is not yet fully constructed (since it's
......
38 38
            # separate the initialization code in the Manager from the
39 39
            # initialization that actually involves interacting with
40 40
            # other components (which may want to use the logger)
41
            extra = { "haizeatime" : "                      "}
42
        return logging.Logger.makeRecord(self, name, lvl, fn, lno, msg, args, exc_info, func, extra)
41
            haizeatime = "                      "
42
        extra = { "haizeatime" : haizeatime}
43
        if sys.version_info[1] <= 4:
44
            name = "[%s] %s" % (haizeatime, name)
45
            return logging.Logger.makeRecord(self, name, lvl, fn, lno, msg, args, exc_info)
46
        else:
47
            return logging.Logger.makeRecord(self, name, lvl, fn, lno, msg, args, exc_info, func, extra)
43 48
    
44 49
    def status(self, msg):
45 50
        self.log(logging.getLevelName("STATUS"), msg)

Also available in: Unified diff