Skip to content

Instantly share code, notes, and snippets.

View Priyanshu9898's full-sized avatar
🎯
Focusing

Priyanshu Malaviya Priyanshu9898

🎯
Focusing
View GitHub Profile
@Priyanshu9898
Priyanshu9898 / logger.py
Created March 7, 2023 13:19
Code for Logger file
import logging
import os
from datetime import datetime
LOG_FILE=f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
logs_path=os.path.join(os.getcwd(),"logs",LOG_FILE)
os.makedirs(logs_path,exist_ok=True)
LOG_FILE_PATH=os.path.join(logs_path,LOG_FILE)
@Priyanshu9898
Priyanshu9898 / exception.py
Created March 7, 2023 07:13
Custom Exception Handling Code
import sys
import logging
import pandas as pd
def error_message_detail(error, error_detail:sys):
_, _, exc_tb = error_detail.exc_info()
file_name = exc_tb.tb_frame.f_code.co_filename
error_message = "Error occured in Python Script name [{0}] Line No. [{1}] Error Message [{2}]".format(file_name, exc_tb.tb_lineno, str(error))