def GetLoggingLocation ( ) : frame = inspect . currentframe ( ) this_file = frame . f_code . co_filename frame = frame . f_back while frame : if this_file == frame . f_code . co_filename : if 'cdbg_logging_location' in frame . f_locals : ret = frame . f_locals [ 'cdbg_logging_location' ] if len ( ret ) != 3 : return ( None , None , None ) return ret frame = frame . f_back return ( None , None , None )
python logging get file name of calling function
Search for and return the file and line number from the log collector .
def GetLoggingLocation():
  """Search for and return the file and line number from the log collector.

  Returns:
    (pathname, lineno, func_name) The full path, line number, and function name
    for the logpoint location.
  """
  frame = inspect.currentframe()
  this_file = frame.f_code.co_filename
  frame = frame.f_back
  while frame:
    if this_file == frame.f_code.co_filename:
      if 'cdbg_logging_location' in frame.f_locals:
        ret = frame.f_locals['cdbg_logging_location']
        if len(ret) != 3:
          return (None, None, None)
        return ret
    frame = frame.f_back
  return (None, None, None)