File size: 827 Bytes
01b4849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bc88c9
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
# Importing Libraries
import logging
import os
from datetime import datetime 
import sys

# Creating and saving log files 
log_dir = "/tmp/logs"
LOG_FILE = f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
logs_path = os.path.join(log_dir,'logs')
os.makedirs(logs_path,exist_ok=True)

LOG_FILE_PATH = os.path.join(logs_path,LOG_FILE)

# Defining Logs message structure
logging.basicConfig(
    #filename = LOG_FILE_PATH,
    format = "[%(asctime)s] %(levelno)s %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)",
    level = logging.INFO,

    handlers=[
        logging.FileHandler(LOG_FILE_PATH),
        logging.StreamHandler(sys.stdout),
    ]
)

# Testing the logger file
'''if __name__ == "__main__":
    logging.info("Logger has started")'''

logger = logging.getLogger('recommendation-system-logger')