Let us say that we built a function in odoo and we want to get data of any function call this function , such as we want to make logging for any caller function fo our function , so we want to get
caller function name
caller function file
calling line in the caller function
and put all of these data in logging file , we can get all of these data as bellow
caller function name :
caller function name
caller function file
calling line in the caller function
and put all of these data in logging file , we can get all of these data as bellow
caller function name :
caller_function = sys._getframe(1).f_code.co_name
caller function file :
caller_filename = sys._getframe(1).f_code.co_filename
calling line in the caller function :
caller_line_number = sys._getframe(1).f_lineno
#Note
we can get the current function name as
current_function = sys._getframe(1).f_code.co_name
and we can add them to logging file from here
No comments:
Post a Comment