libmuscle.manager.logger module

class libmuscle.manager.logger.Formatter(fmt=None, datefmt=None, style='%')[source]

Bases: Formatter

A custom formatter that can format remote messages.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

formatMessage(record: LogRecord) str[source]

Formats a message for a record.

If the record contains a time_stamp attribute, assumes that it is a remote record and formats accordingly, otherwise formats as a local record.

Parameters

record – The LogRecord to format.

Returns

The formatted message.

usesTime() bool[source]

Tells the formatter to make asctime available.

class libmuscle.manager.logger.Logger(log_dir: Optional[Path] = None)[source]

Bases: object

The MUSCLE 3 Manager Logger component.

The Logger component takes log messages and writes them to standard out.

Parameters

log_dir – Directory to write the log file into.

close() None[source]
log_message(instance_id: str, timestamp: Timestamp, level: LogLevel, text: str) None[source]

Log a message.

Parameters
  • instance_id – Identifier of the instance that generated the message.

  • timestamp – Time when this log message was generated, according to the clock on that machine.

  • level – The log level of the message.

  • text – The message text.