sim_platform.diagnostics

Diagnostic logging for the platform process.

Every module logs through logging.getLogger(__name__), so all records sit under the sim_platform logger. As a library the package installs only a NullHandler: nothing is printed unless the application configures logging. The CLI and Desktop call configure_logging(); Python users can call it too or attach their own handlers.

Logged records are diagnostics for maintainers (handled failures with their traceback, lifecycle problems). They are not the experiment record: orders, fills and Agent activity stay in the database and operation logs. Records never include credentials.

class sim_platform.diagnostics.JsonFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

Format one record per line as a JSON object for log collectors.

format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

Parameters:

record (LogRecord)

Return type:

str

sim_platform.diagnostics.configure_logging(level=None, *, json_format=None, stream=None)[source]

Send platform diagnostics to stream (standard error by default).

Parameters:
  • level (str | None) – One of LEVELS. None reads MARKET_LAB_LOG_LEVEL, else warning.

  • json_format (bool | None) – One JSON object per line when True. None reads MARKET_LAB_LOG_FORMAT (json or text), else text.

  • stream (TextIO | None) – Destination; standard error when omitted.

Returns:

The sim_platform logger. Calling again replaces the handler it added before.

Raises:

ValueError – If the level or format name is not recognised.

Return type:

Logger