Trace module reference

Note

This module contains shortcuts for tracing program execution flow.

This contains utilities for logging the program trace and prepending version to the file logs.

micro.common.trace.trace(message=None)[source]

This outputs debug message into logs, which contains the next prefix: TRACE: {filename}:{lineno} in {scope}({locals}) where

  • filename is the name of the file where this tracing shortcut was called
  • lineno is the line of the source file where this tracing call was issued
  • scope is the string representation of scope where this tracing call was issued
  • locals is the representation of variables, which are local to the given scope
Parameters:message (str, None) – Optional message to send alongwith tracing prefix.
micro.common.trace.get_trace_files()[source]

This function returns list of files to trace. A list of files to show trace output from can be passed to the trace() executor within two ways:

1. An environment variable named TRACE_LIST, containing comma-separated list of curdir-relative paths to the source files to trace. Usage:

TRACE_LIST="some_dir/some_file.py,some_dir/some_file1.py" python ailocals_capable_app.py

2. An environment variable named TRACE_FILE, which is a path to a file,comma-separated list of curdir-relative paths to the source files to trace. Usage:

cat "some_dir/some_file.py,some_dir/some_file1.py" > some_dir/trace.csv
TRACE_FILE="some_dir/trace.csv" python ailocals_capable_app.py

If there are both TRACE_FILE and TRACE_LIST passed to os.environ, trace files will be combined from each output. The trace files can also be added with add_trace_file(filename)

Returns:List of files to trace
Return type:list
micro.common.trace.add_trace_file(filename)[source]

Adds path which is relative to os.curdir to the list of tracing files

Parameters:filename
Returns:
micro.common.trace.spewer(frame, s, ignored)[source]

A trace function for sys.settrace that prints every function or method call alongside with its task ID.

micro.common.trace.spew()[source]

Start print program tracing information for every statement.