-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16ac188
commit 4000af1
Showing
6 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
|
||
|
||
class customexception(Exception): | ||
|
||
def __init__(self,error_message,error_details:sys): | ||
self.error_message=error_message | ||
_,_,exc_tb=error_details.exc_info() | ||
print(exc_tb) | ||
|
||
self.lineno=exc_tb.tb_lineno | ||
self.file_name=exc_tb.tb_frame.f_code.co_filename | ||
|
||
def __str__(self): | ||
return "Error occured in python script name [{0}] line number [{1}] error message [{2}]".format( | ||
self.file_name, self.lineno, str(self.error_message)) | ||
|
||
|
||
if __name__=="__main__": | ||
try: | ||
a=1/0 | ||
|
||
except Exception as e: | ||
#print(e) | ||
raise customexception(e,sys) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
import os | ||
from datetime import datetime | ||
|
||
LOG_FILE=f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log" | ||
|
||
log_path=os.path.join(os.getcwd(),"logs") | ||
|
||
os.makedirs(log_path,exist_ok=True) | ||
|
||
LOG_FILEPATH=os.path.join(log_path,LOG_FILE) | ||
|
||
|
||
logging.basicConfig(level=logging.INFO, | ||
filename=LOG_FILEPATH, | ||
format="[%(asctime)s] %(lineno)d %(name)s - %(levelname)s - %(message)s" | ||
|
||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from src.logger.logging import logging | ||
|
||
logging.info("this is myb testing") | ||
|
||
|
||
logging.info(" this my second tesgting") | ||
logging.info(" this my second tesgting") | ||
|
||
logging.info(" this my second tesgting") | ||
logging.info(" this my second tesgting") | ||
logging.info(" this my second tesgting") |