labscript_utils.tracelog.log(log_path=None, module_names=(), sub=False, all=False, mode='w')[source]

Trace and log Python execution.

output includes the time, thread name, containing function name, line number and source line. Indentation before the thread name represents stack depth, indentation before source line is as in the source line itself.

log_path: the path of the desired output file to write to, or None for stdout (default=None) module_names: list of module names that tracing is desired for (default=()) sub: whether submodules of the above modules should be traced (default=False) all: whether all modules should be traced, in which case module_names is ignored (default=False) mode: mode to open the output file in, if log_path is not None (default=’w’)