TraceCollector

class shell_logger.trace_collector.TraceCollector(**kwargs)[source]

Bases: object

Trace a command run in the underlying shell.

Provides an interface for the ShellLogger to run commands with a certain trace (e.g., strace or ltrace).

Initialize the TraceCollector object.

Set up the output file where the trace information will be written.

command(command)[source]

Get the command to be run in the underlying shell.

Return a command that runs a trace on command. E.g., ls -l might get translated to strace -f -c -e 'open' -- ls -l.

Parameters:

command (str) – The command to be traced.

static subclass(trace_subclass)[source]

Mark a class as being a supported trace collector.

This is a class decorator that adds to a list of supported TraceCollector classes for the trace_collector() factory method.

subclasses = [<class 'shell_logger.trace_collector.STraceCollector'>, <class 'shell_logger.trace_collector.LTraceCollector'>]
abstract property trace_args: str

Get the trace command.

The trace command and the arguments you pass to it, but not the command you’re tracing. E.g., return strace -f -c -e “open”.

trace_name = 'undefined'
shell_logger.trace_collector.trace_collector()[source]

Generate trace collectors.

A factory method that returns any subclass of TraceCollector that has the @TraceCollector.subclass decorator applied to it.

Parameters:

**kwargs – Any supported arguments of the TraceCollector subclass.

Return type:

TraceCollector

Returns:

A single instance of a TraceCollector subclass.

STraceCollector

class shell_logger.trace_collector.STraceCollector(**kwargs)[source]

Bases: TraceCollector

Run strace on commands.

An interface between ShellLogger and the strace command.

Initialize the STraceCollector instance.

property trace_args: str

Wraps a command in a strace command.

trace_name = 'strace'

LTraceCollector

class shell_logger.trace_collector.LTraceCollector(**kwargs)[source]

Bases: TraceCollector

Run ltrace on commands.

An interface between ShellLogger and the ltrace command.

Initialize the LTraceCollector instance.

property trace_args

Wraps a command in a ltrace command.

trace_name = 'ltrace'