-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DeepBlockDeepak
committed
Nov 27, 2023
1 parent
2842e93
commit 5b47218
Showing
1 changed file
with
17 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import logging | ||
from logging.handlers import RotatingFileHandler | ||
|
||
LOGGING_LEVEL = ( | ||
logging.INFO | ||
) # (DEBUG, INFO, WARNING, ERROR, CRITICAL) Shows all levels at or above selected | ||
|
||
# Set the logging level here (DEBUG, INFO, WARNING, ERROR, CRITICAL) | ||
LOGGING_LEVEL = logging.INFO | ||
|
||
# Configure global logger | ||
global_logger = logging.getLogger(__name__) | ||
global_logger.setLevel(LOGGING_LEVEL) | ||
log_format = logging.Formatter("[%(asctime)s] [%(module)s/%(levelname)s]: %(message)s") | ||
|
||
file_handler = logging.FileHandler("runtime.log") | ||
# Log format to include timestamp, logger name, log level, and message | ||
log_format = logging.Formatter( | ||
"[%(asctime)s] [%(name)s/%(levelname)s]: %(message)s", "%Y-%m-%d %H:%M:%S" | ||
) | ||
|
||
# File handler with log rotation | ||
file_handler = RotatingFileHandler("runtime.log", maxBytes=1048576, backupCount=5) | ||
file_handler.setFormatter(log_format) | ||
|
||
# Console handler to output logs to the console | ||
console_handler = logging.StreamHandler() | ||
console_handler.setFormatter(log_format) | ||
|
||
# Add handlers to the global logger | ||
global_logger.addHandler(file_handler) | ||
global_logger.addHandler(console_handler) |