Skip to content
v0.1.3

Emitter Module API Reference

This section documents the internals of the emitter module in Bijux CLI.

bijux_cli.contracts.emitter

Defines the contract for the structured output emission service.

This module specifies the EmitterProtocol, a formal interface that any service responsible for serializing data payloads (e.g., to JSON or YAML) and emitting them to an output stream must implement.

EmitterProtocol

Bases: Protocol

Defines the contract for emitting structured output.

This interface specifies the methods for serializing and emitting data in various formats, often integrating with a logging or telemetry system.

emit

emit(
    payload: Any,
    *,
    fmt: OutputFormat | None = None,
    pretty: bool = False,
    level: str = "info",
    message: str = "Emitting output",
    output: str | None = None,
    **context: Any,
) -> None

Serializes and emits a structured data payload.

Parameters:

  • payload (Any) –

    The data payload to serialize and emit.

  • fmt (OutputFormat | None, default: None ) –

    The output format for serialization.

  • pretty (bool, default: False ) –

    If True, pretty-prints the output with indentation.

  • level (str, default: 'info' ) –

    The log level for any accompanying message.

  • message (str, default: 'Emitting output' ) –

    A descriptive message for logging.

  • output (str | None, default: None ) –

    An optional pre-formatted string to emit instead of serializing the payload.

  • **context (Any, default: {} ) –

    Additional key-value pairs for structured logging.

Returns:

  • None ( None ) –
Source code in src/bijux_cli/contracts/emitter.py
def emit(
    self,
    payload: Any,
    *,
    fmt: OutputFormat | None = None,
    pretty: bool = False,
    level: str = "info",
    message: str = "Emitting output",
    output: str | None = None,
    **context: Any,
) -> None:
    """Serializes and emits a structured data payload.

    Args:
        payload (Any): The data payload to serialize and emit.
        fmt (OutputFormat | None): The output format for serialization.
        pretty (bool): If True, pretty-prints the output with indentation.
        level (str): The log level for any accompanying message.
        message (str): A descriptive message for logging.
        output (str | None): An optional pre-formatted string to emit
            instead of serializing the payload.
        **context (Any): Additional key-value pairs for structured logging.

    Returns:
        None:
    """
    ...

flush

flush() -> None

Flushes any buffered output to its destination stream.

Source code in src/bijux_cli/contracts/emitter.py
def flush(self) -> None:
    """Flushes any buffered output to its destination stream."""
    ...