Beispiel #1
0
    def test_verbose_debug_when_emit(self, collectd):
        # Given
        handler = CollectdLogHandler(collectd=collectd)
        handler.verbose = True
        record = make_record(msg="message", level=logging.DEBUG)

        # When an info record is emitted
        handler.emit(record=record)

        # Then info hook is called
        collectd.info.assert_called_once_with("message")
Beispiel #2
0
    def test_non_verbose_when_logger_info(self, collectd):
        # Given
        handler = CollectdLogHandler(collectd=collectd)
        handler.verbose = False
        logger = logging.Logger('some_logger')
        logger.addHandler(handler)

        # When debug is called
        logger.debug('Say cheese: %s %d', 'string', 10)

        # Then debug hook is called
        collectd.debug.assert_called_once_with('Say cheese: string 10')
        collectd.info.assert_not_called()