Beispiel #1
0
 def test_get_logger_invalid(self):
     """ Test the get_logger function."""
     try:
         get_logger('pywbem.blah')
         self.fail('Expected exception for invalid log name')
     except ValueError:
         pass
Beispiel #2
0
    def test_log_output(self, l):  # pylint: disable=blacklisted-name
        test_input = 'all=file:all'

        if VERBOSE:
            print('log filename %s' % TEST_OUTPUT_LOG)

        PywbemLoggers.create_loggers(test_input, TEST_OUTPUT_LOG)

        my_logger = get_logger(LOG_OPS_CALLS_NAME)

        self.assertNotEqual(
            my_logger, None,
            'Valid named logger %s expected.' % LOG_OPS_CALLS_NAME)
        # for name in PywbemLoggers.loggers:
        #    print(PywbemLoggers.get_logger_info(name))
        max_size = 1000
        result = 'This is fake return data'
        return_name = 'Return'
        if max_size and len(repr(result)) > max_size:
            result = '{:.{sz}s}...' \
                .format(repr(result), sz=max_size)
        else:
            result = '%s' % repr(result)

        my_logger.debug('%s: %s: %s', return_name, 'FakeMethodName', result)

        l.check(('pywbem.ops', 'DEBUG',
                 "Return: FakeMethodName: 'This is fake return data'"))
Beispiel #3
0
 def test_get_logger_default(self):
     """ Test the get_logger function."""
     logger = get_logger(LOG_OPS_CALLS_NAME)
     self.assertEqual(len(logger.handlers), 1)
     log_info = PywbemLoggers.get_logger_info(LOG_OPS_CALLS_NAME)
     self.assertEqual(log_info[2], 'none')
     self.assertEqual(log_info[0], 'min')