class_docstr: Customizable traceback for inclusion debug log messages
      
class_docstr_tok: ["Customizable","traceback","for","inclusion","debug","log","messages"]
code: def __call__(self):
      # get the stack description. All but the last three items, which
      # represent the entry into this utility rather than the traceback
      # relevant for the caller
      ftb = self._extract_stack(limit=self.limit + 10)[:-3]
      # each item in `ftb` is
      # (filename, line, object, code-on-line)
      # so entries is a list of (filename, line)
      entries = [
          [mbasename(x[0]), str(x[1])]
          for x in ftb
          # the last entry in the filtered list will always come from
          # this datalad/log.py facility, where the log record
          # was emitted, it is not meaningful to always show a constant
          # trailing end of the traceback
          # more generally, we are hardly ever interested in traceback
          # pieces from this file
          if x[0] != __file__
      ]
      # remove more "uninformative" levels of the stack, given the space
      # constraints of a log message
      entries = [
          e
          for e in entries
          if e[0] not in ("unittest", "logging.__init__")
      ]
  
      if len(entries) > self.limit:
          sftb = "…>"
          entries = entries[-self.limit :]
      else:
          sftb = ""
  
      if not entries:
          return ""
  
      # let's make it more concise
      entries_out = [entries[0]]
      for entry in entries[1:]:
          # if the current filename is the same as the last one on the stack
          # only append the line number to save space
          if entry[0] == entries_out[-1][0]:
              entries_out[-1][1] += ",%s" % entry[1]
          else:
              entries_out.append(entry)
  
      # format the traceback in a compact form
      sftb += ">".join(
          ["%s:%s" % (mbasename(x[0]), x[1]) for x in entries_out]
      )
  
      if self.collide:
          # lets remove part which is common with previous invocation
          prev_next = sftb
          common_prefix = os.path.commonprefix((self.__prev, sftb))
          common_prefix2 = self.__prefix_re.sub("", common_prefix)
  
          if common_prefix2 != "":
              sftb = "…" + sftb[len(common_prefix2) :]
          self.__prev = prev_next
  
      return sftb
  
imports: from contextlib import contextmanager
  from functools import partial
  import inspect
  import logging
  import os
  import sys
  import platform
  import random
  import logging.handlers
  import warnings
  from os.path import basename, dirname
  from collections import defaultdict
  from .utils import is_interactive, optional_args
  from .support import ansi_colors
label_desc: Use image node_id 3 for calling the TraceBack obj's underlying member method code with example usage: obj.__call__() and returns: sftb, str