Esempio n. 1
0
def getRootLogger(level, syslog):
    """Configures our Python stdlib Root Logger"""
    # Convert the supplied log level string
    # into a valid log level constant
    level_string = 'logging.%s' % level.upper()
    level_constant = utils.strToClass(level_string)

    # Set up the logger now
    return utils.setupLogger(level=level_constant, syslog=syslog)
Esempio n. 2
0
    def testSetupLoggerWithLevel(self):
        """Test that levle=logging.DEBUG works"""
        # Since we're really checking if loggers get created properly,
        # make sure to wipe out any existing logging handlers on the Root
        # logger object.
        log = logging.getLogger()
        log.handlers = []

        logger = utils.setupLogger(level=logging.DEBUG)
        self.assertEquals(logger.level, logging.DEBUG)
Esempio n. 3
0
    def testSetupLogger(self):
        """Make sure that the setupLogger() method creates a StreamHandler"""
        # Since we're really checking if loggers get created properly,
        # make sure to wipe out any existing logging handlers on the Root
        # logger object.
        log = logging.getLogger()
        log.handlers = []

        logger = utils.setupLogger()
        self.assertEquals(type(logger.handlers[0]), logging.StreamHandler)
        self.assertEquals(logger.level, logging.WARNING)
Esempio n. 4
0
    def testSetupLoggerWithSyslog(self):
        """Make sure that the setupLogger(syslog='local0') works"""
        # Since we're really checking if loggers get created properly,
        # make sure to wipe out any existing logging handlers on the Root
        # logger object.
        log = logging.getLogger()
        log.handlers = []

        logger = utils.setupLogger(syslog='local0')
        self.assertEquals(type(logger.handlers[0]),
                          logging.handlers.SysLogHandler)
        self.assertEquals(logger.handlers[0].facility, 'local0')
Esempio n. 5
0
 def setUp(self):
     """Clean up before each test"""
     utils.setupLogger()