Skip to content

omnipy.shared.protocols.hub.log

Protocols for objects that expose Omnipy logging helpers.

CLASS DESCRIPTION
CanLog

Protocol for objects that expose a logger and log helper.

CanLog

Bases: Protocol


              flowchart BT
              omnipy.shared.protocols.hub.log.CanLog[CanLog]

              

              click omnipy.shared.protocols.hub.log.CanLog href "" "omnipy.shared.protocols.hub.log.CanLog"
            

Protocol for objects that expose a logger and log helper.

METHOD DESCRIPTION
log

Emit a log message, optionally using an explicit event timestamp.

ATTRIBUTE DESCRIPTION
logger

Return the logger bound to the concrete instance type.

TYPE: Logger

Source code in src/omnipy/shared/protocols/hub/log.py
class CanLog(Protocol):
    """Protocol for objects that expose a logger and log helper."""
    @property
    def logger(self) -> Logger:
        # %% Original docstring (managed by expand_docstr_macros.py) %%
        # {{CANLOG_LOGGER_SUMMARY}}
        #
        # {{CANLOG_LOGGER_DETAILS}}
        """Return the logger bound to the concrete instance type.

        Returns:
            Logger: Logger used by the object for Omnipy log messages.
        """
        ...

    def log(self, log_msg: str, level: int = INFO, datetime_obj: datetime | None = None):
        # %% Original docstring (managed by expand_docstr_macros.py) %%
        # {{CANLOG_LOG_SUMMARY}}
        #
        # {{CANLOG_LOG_DETAILS}}
        """Emit a log message, optionally using an explicit event timestamp.

        Args:
            log_msg: Message text to send to the logger.
            level: Standard library logging level.
            datetime_obj: Timestamp to attach to the record instead of wall-clock time.
        """
        ...

logger property

logger: Logger

Return the logger bound to the concrete instance type.

RETURNS DESCRIPTION
Logger

Logger used by the object for Omnipy log messages.

TYPE: Logger

log

log(log_msg: str, level: int = INFO, datetime_obj: datetime | None = None)

Emit a log message, optionally using an explicit event timestamp.

PARAMETER DESCRIPTION
log_msg

Message text to send to the logger.

TYPE: str

level

Standard library logging level.

TYPE: int DEFAULT: INFO

datetime_obj

Timestamp to attach to the record instead of wall-clock time.

TYPE: datetime | None DEFAULT: None

Source code in src/omnipy/shared/protocols/hub/log.py
def log(self, log_msg: str, level: int = INFO, datetime_obj: datetime | None = None):
    # %% Original docstring (managed by expand_docstr_macros.py) %%
    # {{CANLOG_LOG_SUMMARY}}
    #
    # {{CANLOG_LOG_DETAILS}}
    """Emit a log message, optionally using an explicit event timestamp.

    Args:
        log_msg: Message text to send to the logger.
        level: Standard library logging level.
        datetime_obj: Timestamp to attach to the record instead of wall-clock time.
    """
    ...