libmuscle.manager.logger module

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

Bases: logging.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: logging.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[pathlib.Path] = None, log_level: Optional[str] = None)[source]

Bases: object

The MUSCLE3 Manager Logger component.

The Logger component configures the local logging system to output to the central log file, and it accepts messages from remote instances to write to it as well. Log levels are also set here.

Create a Logger.

Log levels may be any of the Python predefined log levels, i.e. critical, error, warning, info and debug, and they’re case_insensitive.

Parameters
  • log_dir – Directory to write the log file into.

  • log_level – Log level to set.

close() None[source]
log_message(instance_id: str, timestamp: libmuscle.timestamp.Timestamp, level: libmuscle.logging.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.