-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPythonLogger.py
More file actions
33 lines (25 loc) · 850 Bytes
/
PythonLogger.py
File metadata and controls
33 lines (25 loc) · 850 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
27
28
29
30
31
32
33
import logging
import os
from datetime import datetime
DATE_FORMAT = '%d-%m-%Y'
SUCESS_FILENAME = 'success_logs/ProjectName-{}.log'
ERROR_FILENAME = 'error_logs/ProjectName-{}.log'
DIRECTORY_SUCCESS = "success_logs/"
DIRECTORY_ERROR = "error_logs/"
FORMAT_LOGGING = '%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s:%(message)s'
DATE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
def log_this_logger(exe):
"""
This will log the message from the exe variable
:return: Null
"""
today = datetime.today().strftime(DATE_FORMAT)
filename = SUCESS_FILENAME.format(today)
if not os.path.exists(DIRECTORY_SUCCESS):
os.makedirs(DIRECTORY_SUCCESS)
logging.basicConfig(
filename=filename, level=logging.DEBUG,
format=FORMAT_LOGGING,
datefmt=DATE_TIME_FORMAT
)
logging.debug(exe)