-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
36 lines (28 loc) · 1.04 KB
/
Copy pathlogger.py
File metadata and controls
36 lines (28 loc) · 1.04 KB
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
27
28
29
30
31
32
33
34
35
36
import logging
class SetupLoger:
"""
Logging setup class for configuring a logger instance.
This class provides functionality to set up a logger instance with the desired formatting
and handlers for logging messages.
Attributes:
logger (logging.Logger): The configured logger instance.
"""
def __init__(self):
"""
Initialize the SetupLoger instance.
This constructor sets up the logger by calling the _setup_logger method.
"""
self.logger = self._setup_logger()
def _setup_logger(self) -> logging.Logger:
"""
Configure and return a logger instance.
Returns:
logging.Logger: The configured logger instance.
"""
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
return logger