inital commit
This commit is contained in:
29
scrapper/Basic/log_manager.py
Normal file
29
scrapper/Basic/log_manager.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import os
|
||||
|
||||
|
||||
def get_logging():
|
||||
|
||||
log_dir = 'logs'
|
||||
if not os.path.exists(log_dir):
|
||||
os.makedirs(log_dir)
|
||||
|
||||
|
||||
date_str = datetime.now().strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
log_filename = os.path.join(log_dir, f'app_{date_str}.log')
|
||||
|
||||
|
||||
if not os.path.exists(log_filename):
|
||||
|
||||
logging.basicConfig(filename=log_filename, filemode='w', level=logging.ERROR,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
else:
|
||||
|
||||
logging.basicConfig(filename=log_filename, filemode='a', level=logging.ERROR,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
return logging
|
||||
|
||||
Reference in New Issue
Block a user