Update src/recommendationSystem/logging/__init__.py
Browse files
src/recommendationSystem/logging/__init__.py
CHANGED
@@ -1,30 +1,31 @@
|
|
1 |
-
# Importing Libraries
|
2 |
-
import logging
|
3 |
-
import os
|
4 |
-
from datetime import datetime
|
5 |
-
import sys
|
6 |
-
|
7 |
-
# Creating and saving log files
|
8 |
-
|
9 |
-
|
10 |
-
os.
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
logging.
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
logger = logging.getLogger('recommendation-system-logger')
|
|
|
1 |
+
# Importing Libraries
|
2 |
+
import logging
|
3 |
+
import os
|
4 |
+
from datetime import datetime
|
5 |
+
import sys
|
6 |
+
|
7 |
+
# Creating and saving log files
|
8 |
+
log_dir = "/tmp/logs"
|
9 |
+
LOG_FILE = f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
|
10 |
+
logs_path = os.path.join(log_dir,'logs')
|
11 |
+
os.makedirs(logs_path,exist_ok=True)
|
12 |
+
|
13 |
+
LOG_FILE_PATH = os.path.join(logs_path,LOG_FILE)
|
14 |
+
|
15 |
+
# Defining Logs message structure
|
16 |
+
logging.basicConfig(
|
17 |
+
#filename = LOG_FILE_PATH,
|
18 |
+
format = "[%(asctime)s] %(levelno)s %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)",
|
19 |
+
level = logging.INFO,
|
20 |
+
|
21 |
+
handlers=[
|
22 |
+
logging.FileHandler(LOG_FILE_PATH),
|
23 |
+
logging.StreamHandler(sys.stdout),
|
24 |
+
]
|
25 |
+
)
|
26 |
+
|
27 |
+
# Testing the logger file
|
28 |
+
'''if __name__ == "__main__":
|
29 |
+
logging.info("Logger has started")'''
|
30 |
+
|
31 |
logger = logging.getLogger('recommendation-system-logger')
|