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.
10585
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)
841610
def get_relativelinenumbertable(self):
        

        lnt = self.get_linenumbertable()
        if lnt:
            lineoff = lnt[0][1]
            return tuple((o, l - lineoff) for (o, l) in lnt)
        else:
            return tuple()
544809
def file_loc():
    """"""
    import sys
    import inspect
    try:
        raise Exception
    except:
        file_ = '.../' + '/'.join((inspect.currentframe().f_code.co_filename.split('/'))[-3:])
        line_ = sys.exc_info()[2].tb_frame.f_back.f_lineno
        return "{}:{}".format(file_, line_)
894653
def getfullfilename(file_path):
        ''' 
        '''
        warnings.warn("getfullfilename() is deprecated and will be removed in near future. Use chirptext.io.write_file() instead", DeprecationWarning)
        if file_path:
            return os.path.basename(file_path)
        else:
            return ''
9927
def _GetLineNumbers(code_object):
  
  # Get the line number deltas, which are the odd number entries, from the
  # lnotab. See
  # https://svn.python.org/projects/python/branches/pep-0384/Objects/lnotab_notes.txt
  # In Python 3, this is just a byte array. In Python 2 it is a string so the
  # numerical values have to be extracted from the individual characters.
  if six.PY3:
    line_incrs = code_object.co_lnotab[1::2]
  else:
    line_incrs = (ord(c) for c in code_object.co_lnotab[1::2])
  current_line = code_object.co_firstlineno
  for line_incr in line_incrs:
    current_line += line_incr
    yield current_line
841415
def traceit(frame, event, arg):
    

    import linecache
    try:
        if event == "line":
            lineno = frame.f_lineno
            filename = frame.f_globals.get("__file__")

            if (filename.endswith(".pyc") or filename.endswith(".pyo")):
                filename = filename[:-1]

            name = frame.f_globals["__name__"]
            line = linecache.getline(filename, lineno)
            if name.startswith('ambry'):
                print "%s:%s: %s" % (name, lineno, line.rstrip())

    finally:
        return traceit
131870
def _find_curr_line(self, prev=False):
        
        curr_pos = self.filehandle.tell()

        # jump back 15k characters (at most) and find last newline char
        jump_back = min(self.filehandle.tell(), 15000)
        self.filehandle.seek(-jump_back, 1)
        buff = self.filehandle.read(jump_back)
        self.filehandle.seek(curr_pos, 0)

        if prev and self.prev_pos is not None and self.prev_pos == curr_pos:
            # Number of characters to show before/after the log offset
            error_context = 300
            self.filehandle.seek(-error_context, 1)
            buff = self.filehandle.read(curr_pos)
            hr = "-" * 60
            print("Fatal log parsing loop detected trying to find previous "
                  "log line near offset %s in %s:\n\n%s\n%s\n"
                  "<--- (current log parsing offset) \n%s\n%s\n"
                  % (curr_pos, self.name, hr, buff[:error_context],
                     buff[error_context:error_context + 1], hr),
                  file=sys.stderr)
            raise SystemExit("Cannot parse %s with requested options"
                             % self.filehandle.name)
        else:
            self.prev_pos = curr_pos
        buff = buff.decode("utf-8", "replace")
        newline_pos = buff.rfind('\n')
        if prev:
            newline_pos = buff[:newline_pos].rfind('\n')

        # move back to last newline char
        if newline_pos == -1:
            self.filehandle.seek(0)
            return self.next()

        self.filehandle.seek(newline_pos - jump_back + 1, 1)

        # roll forward until we found a line with a datetime
        try:
            logevent = self.next()
            while not logevent.datetime:
                logevent = self.next()

            return logevent
        except StopIteration:
            # reached end of file
            return None
622783
def get_line_configuration_message(self, line_number):
        
        if line_number not in self._line_configuration_message_cache:
            line_bytes = self.get_bytes(line_number)
            if line_bytes is not None:
                line_bytes = bytes([line_number & 255]) + line_bytes
                line_bytes += bytes([self.is_last(line_number)])
                line_bytes += crc8(line_bytes).digest()
            self._line_configuration_message_cache[line_number] = line_bytes
            del line_bytes
        line = self._line_configuration_message_cache[line_number]
        if line is None:
            # no need to cache a lot of empty lines
            line = (bytes([line_number & 255]) +
                    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +
                    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
            line += crc8(line).digest()
        return line
2968
def getLoggingLocation(self):
		""""""
		if sys.platform == "win32":
			modulePath = os.path.realpath(__file__)
			modulePath = modulePath[:modulePath.rfind("/")]
			return modulePath
		else:
			return "/tmp"
		return ""
837220
function winstonFormatter (options) {
    // get callsite to for filename:linenumber where logger was called
    var callsite = callsites()[10]
    // string to log
    return options.level + ': '
        + (typeof options.message === 'string' ? options.message : '' )
        + ' (' + callsite.getFileName() + ':'
        + callsite.getLineNumber() + ':'
        + callsite.getColumnNumber() + ')'
        + (typeof options.meta === 'object' && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' )
}
69179
def _get_log_prior_cl_func(self):
        
        return SimpleCLFunction.from_string('''
            mot_float_type _computeLogPrior(local const mot_float_type* x, void* data){
                return ''' + self._log_prior_func.get_cl_function_name() + '''(x, data);
            }
        ''', dependencies=[self._log_prior_func])
1229925
def get_source_code(filename, lineno, module_globals):
    
    import linecache
    linecache.checkcache(filename)
    source_code = linecache.getline(filename, lineno, module_globals)
    # In case of a multi-line statement, lineno is usually the last line.
    # We are checking for missing open brackets and add earlier code lines.
    while is_source_code_missing_open_brackets(source_code):
        if lineno <= 0:
            break
        lineno -= 1
        source_code = "".join([linecache.getline(filename, lineno, module_globals), source_code])
    return source_code
1077826
public String getLogLocation() {
        if (logInstanceBrowser instanceof MainLogRepositoryBrowserImpl) {
            return ((MainLogRepositoryBrowserImpl) logInstanceBrowser).getLocation().getAbsolutePath();
        } else {
            return ((OneInstanceBrowserImpl) logInstanceBrowser).getLocation().getAbsolutePath();
        }

    }
1215495
public int getLineNumber(Location start) {
        LineNumberTableAttr table = mOldLineNumberTable;
        if (table == null) {
            table = mLineNumberTable;
        }

        if (table == null || start.getLocation() < 0) {
            return -1;
        } else {
            return table.getLineNumber(start);
        }
    }
931388
def get_line_number(line_map, offset):
    """"""
    for lineno, line_offset in enumerate(line_map, start=1):
        if line_offset > offset:
            return lineno
    return -1
474818
def _format_trace(trace):
    
    lines = []
    for fname, lineno, func, src, _ in trace:
        if src:
            for line in src:
                lines.append('    '+line.strip()+'\n')
        lines.append('  %s:%4d in %s\n' % (fname, lineno, func))
    return ''.join(lines)
1090552
function getLineNumber() {
  var lines = this.source
    .slice(0, this.source.indexOf(this.entry) + this.entry.length)
    .match(/\n/g)
    .slice(1);

  // Offset by 2 because the first line number is before a line break and the
  // last line doesn't include a line break.
  return lines.length + 2;
}