forked from lzhang666/portal-unit-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logtools.py
37 lines (28 loc) · 933 Bytes
/
logtools.py
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
37
"""
The logging tools used throughout this package.
"""
# Load additional packages
import logging
import sys
class CustomLogging:
"""
Logging object for the package.
:param name: name of the logger.
"""
def __init__(self, name: str):
self.__logger = logging.getLogger(name)
self.__logger.setLevel(logging.DEBUG)
# Create handlers
self.__streamHandler = logging.StreamHandler(sys.stdout)
self.__streamHandler.setLevel(logging.DEBUG)
# Create formatters and add it to handlers
self.__briefFormatter = logging.Formatter('%(levelname)-8s %(message)s')
self.__streamHandler.setFormatter(self.__briefFormatter)
# Add handlers to logger
self.__logger.addHandler(self.__streamHandler)
def get_logger(self):
"""
Gets the logger object.
:return: Returns the logger.
"""
return self.__logger