"""
return float(counter) / 10.**(n_digits(counter)-1.) in (1., 2., 3., 6.)
-
-def test_short_level_format():
- """ quick test of :py:class:`ShortLevelFormatter` """
-
- logger = logging.getLogger('logtest')
- logger.setLevel(DEBUG)
- handler = logging.StreamHandler()
- handler.setLevel(DEBUG)
- formatter = ShortLevelFormatter(
- '%(asctime)s:%(msecs)03d %(shortlevel)s| %(msg)s'
- ' [regular levelname=%(levelname)s]',
- datefmt='%H:%M:%S')
- handler.setFormatter(formatter)
- logger.addHandler(handler)
-
- # 'application' code
- logger.debug('debug message')
- logger.info('info message')
- logger.warn('warn message')
- logger.error('error message')
- logger.critical('critical message')
- logger.log(15, 'unknown level')
- logger.log(NOTSET, 'level not set')
-
- # add notice level
- notice = (logging.INFO + logging.WARNING)/2
- formatter.add_level(notice, 'note')
- logger.log(notice, 'more important than info but no warning nor error')
-
- # try if exception formatting still works:
- try:
- logger.info('this is what an exception looks like:')
- impossible_result = 1/0
- logger.critical('just divided 1/0! The result is {0}'
- .format(impossible_result))
- except ZeroDivisionError:
- logger.exception('1/0 still does not work!', exc_info=True)
-
- # done
- logger.info('done testing')
-
-def test_get_logger():
- log = get_logger('logger_test')
- log2 = get_logger('logger_test')
- print(log == log2)
-
-
-def test_line_counter():
- log = get_logger('logger_test', max_lines=10)
- for idx in range(20):
- for _ in range(20):
- log.debug('should not show nor count')
- print('calling log for idx {0}'.format(idx))
- log.info('logging with idx {0}', idx)
- log.log_count_if_interesting(idx)
-
-
-def test_error_in_formatting():
- log = get_logger('logger_test')
- log.warn('forgot to add argument {} and {1} and {cnf} to format string')
- log.warn('wrong number {} of arguments {}', 1)
-
-if __name__ == '__main__':
- #test_short_level_format()
- #test_get_logger()
- #test_line_counter()
- test_error_in_formatting()