-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloggingConfig.py
More file actions
26 lines (18 loc) · 801 Bytes
/
loggingConfig.py
File metadata and controls
26 lines (18 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! usr/env/bin python3
import logging
def configureLogging(loggingLevel, loggerName: str) -> logging.Logger:
# Create a logger instance with the specified name
logger = logging.getLogger(loggerName)
logger.setLevel(loggingLevel)
# Create a console handler for displaying log messages
console_handler = logging.StreamHandler()
console_handler.setLevel(loggingLevel)
# Create a formatter and add it to the console handler
formatter = logging.Formatter("(%(asctime)s) %(name)s %(levelname)s: %(message)s", "%d.%m. %H:%M:%S")
console_handler.setFormatter(formatter)
# Add the console handler to the logger
logger.addHandler(console_handler)
return logger
if __name__ == "__main__":
L = configureLogging(logging.INFO, __name__)
L.info("uwuw")