# 记录日志 logger.debug('This is a DEBUG message') logger.info('This is an INFO message') logger.warning('This is a WARNING message') logger.error('This is an ERROR message') logger.critical('This is a CRITICAL message')
控制台输出:
1 2 3 4 5
2024-09-16 11:16:05,188 - stream_logger - DEBUG - This is a DEBUG message 2024-09-16 11:16:05,188 - stream_logger - INFO - This is an INFO message 2024-09-16 11:16:05,189 - stream_logger - WARNING - This is a WARNING message 2024-09-16 11:16:05,189 - stream_logger - ERROR - This is an ERROR message 2024-09-16 11:16:05,189 - stream_logger - CRITICAL - This is a CRITICAL message
# 记录日志 logger.debug('This is a DEBUG message') logger.info('This is an INFO message') logger.warning('This is a WARNING message') logger.error('This is an ERROR message') logger.critical('This is a CRITICAL message')
log/file_log.log输出:
1 2 3 4 5
2024-09-16 11:20:29,829 - file_logger - DEBUG - This is a DEBUG message 2024-09-16 11:20:29,829 - file_logger - INFO - This is an INFO message 2024-09-16 11:20:29,829 - file_logger - WARNING - This is a WARNING message 2024-09-16 11:20:29,829 - file_logger - ERROR - This is an ERROR message 2024-09-16 11:20:29,829 - file_logger - CRITICAL - This is a CRITICAL message
# 测试日志输出 for i inrange(10000): logger.debug('This is a debug message') logger.info('This is an info message') logger.warning('This is a warning message') logger.error('This is an error message') logger.critical('This is a critical message')
# 测试日志输出 for i inrange(100): logger.debug('This is a debug message') logger.info('This is an info message') logger.warning('This is a warning message') logger.error('This is an error message') logger.critical('This is a critical message')
# 记录更多日志 logger.warning('This is a WARNING message') logger.error('This is an ERROR message') logger.critical('This is a CRITICAL message')
控制台输出:
1 2 3 4 5
2024-09-16 11:39:34,945 - formatted_logger - DEBUG - This is a DEBUG message 2024-09-16 11:39:34,946 - formatted_logger - INFO - This is an INFO message WARNING: This is a WARNING message (2024-09-16 11:39:34,946) ERROR: This is an ERROR message (2024-09-16 11:39:34,946) CRITICAL: This is a CRITICAL message (2024-09-16 11:39:34,946)
# 记录日志 logger.debug('This is a DEBUG message') logger.info('This is an INFO message with special keyword') logger.warning('This is a WARNING message') logger.error('This is an ERROR message with special keyword') logger.critical('This is a CRITICAL message')
控制台输出:
1 2
2024-09-16 11:45:00,784 - filtered_logger - INFO - This is an INFO message with special keyword 2024-09-16 11:45:00,785 - filtered_logger - ERROR - This is an ERROR message with special keyword