harvestbuddy-api / logger.py
sohok's picture
Init commit from local
486275c
raw
history blame contribute delete
491 Bytes
import os, logging as lg
def custom_log(log_lvl, str_log):
path = os.path.join(os.getcwd(), 'logHarvestBuddy-API.log')
if log_lvl == 'info':
lg.basicConfig(filename=path, level=lg.INFO, format='%(asctime)s %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
lg.info('Starting HarvestBuddy-API service')
if log_lvl == 'error':
lg.basicConfig(filename=path, level=lg.ERROR, format='%(asctime)s %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
lg.error(str_log)