Skip to content
Back to top
View this page
Edit this page

# xonsh.tracer

Implements a xonsh tracer.

class xonsh.tracer.TracerAlias(threadable=True, **kwargs)

  Tool for tracing xonsh code as it runs.

  exception Error(message: str, errno=1)

    Special case, when raised, the traceback will not be shown. Instead the process with exit with error code and message

    add_note(note, /)

      Add a note to the exception

    with_traceback(tb, /)

      Set self.__traceback__ to tb and return self.

    args
  build()

    Sub-classes should return constructed ArgumentParser

  create_parser(func=None, has_args=False, allowed_params=None, **kwargs) → ArgParser

    create root parser

  err(*args, **kwargs)

    Write text to error stream

  out(*args, **kwargs)

    Write text to output stream

  write_to(stream: str, *args, **kwargs)
  xonsh_complete(command, **kwargs)
  property parser

class xonsh.tracer.TracerType(*args, **kwargs)

  Represents a xonsh tracer object, which keeps track of all tracing state. This is a singleton.

  color_output(usecolor)

    Specify whether or not the tracer output should be colored.

  off_files(_args, files: Annotated[Iterable[str], (), 'nargs', '*', 'completer', None] = ('__file__',))

    removes selected files fom tracing.

    Parameters:
      files

        file paths to stop watching, use `__file__` (default) to select the current file.

  on_files(_args, files: Annotated[Iterable[str], (), 'nargs', '*', 'completer', None] = ('__file__',))

    begins tracing selected files.

    Parameters:
      _args

        argv from alias parser

      files

        file paths to watch, use “__file__” (default) to select the current file.

  start(filename)

    Starts tracing a file.

  stop(filename)

    Stops tracing a file.

  toggle_color(toggle: Annotated[bool, ((), (('type', <function to_bool at 0x77972bcb6da0>), ('completer', None)))]=False)

    output color management for tracer

    Parameters:
      toggle

        true/false, y/n, etc. to toggle color usage.

  trace(frame, event, arg, *, find_file=<function find_file>, print_color=<function print_color>)

    Implements a line tracing function.

  valid_events = frozenset({'call', 'line'})

xonsh.tracer.tracer_format_line(fname, lineno, line, color=True, lexer=None, formatter=None)

  Formats a trace line suitable for printing.