cyst.api.configuration.infrastructure

Provides configuration mechanisms to control the underlying infrastructure:
  • Logging (cyst.api.configuration.infrastructure.log)

  • Simulation/emulation switching (to be added…)

cyst.api.configuration.infrastructure.infrastructure

class cyst.api.configuration.infrastructure.infrastructure.InfrastructureConfig(log: ~typing.List[~cyst.api.configuration.infrastructure.log.LogConfig] | None = None, ref: str = <factory>, name: str = '__infrastructure', id: str = '')

Bases: ConfigItem

Infrastructure configuration serves for configuring the underlying machinery that powers CYST. As such, it is used for log setting, simulation modes, etc.

Parameters:

log (Optional[List[LogConfig]]) – Configuration of system logs.

cyst.api.configuration.infrastructure.log

class cyst.api.configuration.infrastructure.log.LogSource(*values)

Bases: Enum

Categories of log sources.

Possible values:
SYSTEM:

Activities of the environment; set up, tear down, exception handling, etc.

MESSAGING:

Logging of messages that are traversing the simulation.

SERVICE:

Logging of active services’ events.

MODEL:

Logging of models’ events.

class cyst.api.configuration.infrastructure.log.LogType(*values)

Bases: Enum

Log entries structure.

Possible values:
TEXT:

Log entries are plain texts. One entry per line.

JSON:

Log entries are JSON. The whole log is not JSON-compliant, because of missing top-level object.

class cyst.api.configuration.infrastructure.log.LogConfig(source: ~cyst.api.configuration.infrastructure.log.LogSource, log_level: int, log_type: ~cyst.api.configuration.infrastructure.log.LogType, log_console: bool, log_file: bool, file_path: str = '', ref: str = <factory>, name: str = '__log', id: str = '')

Bases: ConfigItem

CYST provides what we feel are sensible defaults for logging and this configuration enables slight corrections of this default. The logging is built upon Python’s logging framework. Each of log sources is assigned a named logger with the names ‘system’, ‘messaging’, ‘service.’, and ‘model.’ respectively.

For full customization, you can disable a log by setting log_console and log_file options to False, and then you can use Python’s logging facilities to set the system up to your liking.

Parameters:
  • source (LogSource) – Source of the logs. While system and messaging logs will always work as expected, service and model logs require their authors to abide by a convention and use the logs named ‘service.xxx’ and ‘model.xxx’.

  • log_level (int) – A level of messages to log. It is best to follow categories of Python’s logging framework and use one of logging.(CRITICAL, ERROR, WARNING, INFO, DEBUG).

  • log_type (LogType) – A type of logging to use. Mainly depends on whether you want a machine to process it or not.

  • log_console (bool) – Enable or disable logging to console.

  • log_file (bool) – Enable or disable logging to file. If logging to file is enabled, file_path must be specified.

  • file_path (str) – A path to file that should be used for logging. If logging to file is not enabled, file is not opened/created.