def test_global_functions(self): handler = logbook.TestHandler() with handler: logbook.debug('a debug message') logbook.info('an info message') logbook.warn('warning part 1') logbook.warning('warning part 2') logbook.notice('notice') logbook.error('an error') logbook.critical('pretty critical') logbook.log(logbook.CRITICAL, 'critical too') self.assert_(handler.has_debug('a debug message')) self.assert_(handler.has_info('an info message')) self.assert_(handler.has_warning('warning part 1')) self.assert_(handler.has_warning('warning part 2')) self.assert_(handler.has_notice('notice')) self.assert_(handler.has_error('an error')) self.assert_(handler.has_critical('pretty critical')) self.assert_(handler.has_critical('critical too')) self.assertEqual(handler.records[0].logger_name, 'generic') self.assertEqual(handler.records[0].channel, None)
def test_global_functions(self): handler = logbook.TestHandler() with handler: logbook.debug('a debug message') logbook.info('an info message') logbook.warn('warning part 1') logbook.warning('warning part 2') logbook.notice('notice') logbook.error('an error') logbook.critical('pretty critical') logbook.log(logbook.CRITICAL, 'critical too') self.assert_(handler.has_debug('a debug message')) self.assert_(handler.has_info('an info message')) self.assert_(handler.has_warning('warning part 1')) self.assert_(handler.has_warning('warning part 2')) self.assert_(handler.has_notice('notice')) self.assert_(handler.has_error('an error')) self.assert_(handler.has_critical('pretty critical')) self.assert_(handler.has_critical('critical too')) self.assertEqual(handler.records[0].channel, 'Generic') self.assertEqual(handler.records[0].dispatcher, None)
def test_global_functions(activation_strategy): with activation_strategy(logbook.TestHandler()) as handler: logbook.debug('a debug message') logbook.info('an info message') logbook.warn('warning part 1') logbook.warning('warning part 2') logbook.notice('notice') logbook.error('an error') logbook.critical('pretty critical') logbook.log(logbook.CRITICAL, 'critical too') assert handler.has_debug('a debug message') assert handler.has_info('an info message') assert handler.has_warning('warning part 1') assert handler.has_warning('warning part 2') assert handler.has_notice('notice') assert handler.has_error('an error') assert handler.has_critical('pretty critical') assert handler.has_critical('critical too') assert handler.records[0].channel == 'Generic' assert handler.records[0].dispatcher is None
def test_global_functions(self): handler = logbook.TestHandler() handler.push_thread() try: logbook.debug('a debug message') logbook.info('an info message') logbook.warn('warning part 1') logbook.warning('warning part 2') logbook.notice('notice') logbook.error('an error') logbook.critical('pretty critical') logbook.log(logbook.CRITICAL, 'critical too') finally: handler.pop_thread() self.assert_(handler.has_debug('a debug message')) self.assert_(handler.has_info('an info message')) self.assert_(handler.has_warning('warning part 1')) self.assert_(handler.has_warning('warning part 2')) self.assert_(handler.has_notice('notice')) self.assert_(handler.has_error('an error')) self.assert_(handler.has_critical('pretty critical')) self.assert_(handler.has_critical('critical too')) self.assertEqual(handler.records[0].channel, 'Generic') self.assertEqual(handler.records[0].dispatcher, None)