Changed log level.
All checks were successful
Build Ragnar anti spam bot / Build (push) Successful in 1m9s

This commit is contained in:
retoor 2024-12-17 13:08:00 +01:00
parent 1e7de46326
commit e8b0797ebe
3 changed files with 37 additions and 2 deletions

5
app.log Normal file
View File

@ -0,0 +1,5 @@
2024-12-17 13:06:42,285 - __main__ - DEBUG - This is a debug message
2024-12-17 13:06:42,286 - __main__ - INFO - This is an info message
2024-12-17 13:06:42,286 - __main__ - WARNING - This is a warning message
2024-12-17 13:06:42,286 - __main__ - ERROR - This is an error message
2024-12-17 13:06:42,286 - __main__ - CRITICAL - This is a critical message

29
logtest.py Normal file
View File

@ -0,0 +1,29 @@
import logging
# Create or get the root logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) # Set the logging level
# Create a file handler
file_handler = logging.FileHandler('app.log')
file_handler.setLevel(logging.DEBUG) # Set the level for this handler
# Create a console handler (optional, for logging to the console too)
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
# Create a logging format
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler.setFormatter(formatter)
console_handler.setFormatter(formatter)
# Add the handlers to the logger
logger.addHandler(file_handler)
logger.addHandler(console_handler)
# Log some messages
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")

View File

@ -1,8 +1,9 @@
import logging
import sys
file_handler = logging.FileHandler("ragnar.log")
file_handler.setLevel(logging.INFO)
file_handler = logging.FileHandler('ragnar.log')
file_handler.setLevel(logging.DEBUG)
logging.basicConfig(
level=logging.DEBUG,