-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Logging function name where error occurs * updated text
- Loading branch information
1 parent
533965d
commit df2d47a
Showing
2 changed files
with
43 additions
and
4 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
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,32 @@ | ||
import logging | ||
import time | ||
import functools | ||
|
||
def pyciemss_logging_wrappper( function): | ||
def wrapped(*args, **kwargs): | ||
try: | ||
start_time = time.perf_counter() | ||
result = function(*args, **kwargs) | ||
end_time = time.perf_counter() | ||
logging.info( | ||
f"Elapsed time for {function.__name__}:", | ||
end_time - start_time | ||
) | ||
return result | ||
except Exception as e: | ||
|
||
log_message = f""" | ||
############################### | ||
There was an exception in pyciemss | ||
Error occured in function: {function.__name__} | ||
Function docs : {function.__doc__} | ||
################################ | ||
""" | ||
logging.exception(log_message) | ||
raise e | ||
functools.update_wrapper(wrapped, function) | ||
return wrapped |