#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Techies' Stasis Trap

:copyright: (c) 2014 Runzhou Li (Leo)
:license: The MIT License (MIT), see LICENSE for details.
"""

from logging import Handler, NOTSET

_ref_atributes = [
    '%(levelname)s',
    '%(name)s',
    '%(pathname)s',
    '%(module)s',
    '%(funcName)s',
    '%(lineno)d',
    '%(message)s'
]

'''
Reference log format, best used with UniQueue or CountQueue
'''
REF_LOG_FORMAT = ':'.join(_ref_atributes)


class QueueHandler(Handler):

    '''
    Queue Logging Handler

    Inherits standard logging.Handler that emits to any standard Queue
    compatible implementations. Including the ones in techies.landmines module
    '''

    def __init__(self, q, level=NOTSET):
        super(QueueHandler, self).__init__(level)
        self.q = q

    def emit(self, record):
        try:
            self.q.put(self.format(record))
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record)

@@ -167,16 +167,27 @@
 s.%0A%22%22%22%0A%0A
+import sys%0A
 from log
@@ -757,49 +757,146 @@
     
-super(QueueHandler, self).__init__(level)
+if sys.version_info%5B:2%5D %3E (2, 6):%0A            super(QueueHandler, self).__init__(level)%0A        else:%0A            Handler.__init__(level)%0A
 %0A   

fix the problem caused by old style class logging.Handler in python 2.6.x