bridge.logging module#

Project-wide logging setup. Provides plaintext logs for CLI, JSON lines for API, and conservative defaults for library use; dials down noisy third-party loggers. Defines a custom BridgeLogger with convenience methods for common event types.

class bridge.logging.BridgeLogger(name, level=0)[source]#

Bases: Logger

Logger with extra convenience methods:

.conflict(), .exact(), .added(), .note()

Behaves like a normal logger (msg, *args, **kwargs).

Event types: - CONFLICT (.conflict()):

Indicates a conflict between source and target metadata. For example, when existing bio.tools metadata differs from GitHub metadata.

  • EXACT (.exact()):

    Indicates an exact match between source and target metadata. For example, when existing bio.tools metadata matches GitHub metadata.

  • ADDED (.added()):

    Indicates that new metadata has been added from source to target. For example, when GitHub metadata is used to populate missing bio.tools metadata.

  • UNCHANGED (.unchanged()):

    Indicates that existing metadata remains unchanged. For example, when bio.tools metadata is retained as is.

  • NOTE (.note()):

    General informational messages that do not fit other categories.

added(msg, *args, **kwargs)[source]#

Log an “added” event.

Parameters:
  • msg (str) – The log message.

  • *args – Positional arguments for the log message.

  • **kwargs – Keyword arguments for the log message.

conflict(msg, *args, **kwargs)[source]#

Log a “conflict” event.

Parameters:
  • msg (str) – The log message.

  • *args – Positional arguments for the log message.

  • **kwargs – Keyword arguments for the log message.

exact(msg, *args, **kwargs)[source]#

Log an “exact match” event.

Parameters:
  • msg (str) – The log message.

  • *args – Positional arguments for the log message.

  • **kwargs – Keyword arguments for the log message.

note(msg, *args, **kwargs)[source]#

Log a “note” event.

Parameters:
  • msg (str) – The log message.

  • *args – Positional arguments for the log message.

  • **kwargs – Keyword arguments for the log message.

unchanged(msg, *args, **kwargs)[source]#

Log an “unchanged” event.

Parameters:
  • msg (str) – The log message.

  • *args – Positional arguments for the log message.

  • **kwargs – Keyword arguments for the log message.

bridge.logging.get_user_logger()[source]#

Get the user-facing logger.

Returns:

The user-facing logger.

Return type:

logging.Logger

bridge.logging.setup_logging(mode='package')[source]#

Configure global logging for the bridge project.

Parameters:

mode (Literal["cli", "api", "package"]) – One of: “cli”, “api”, or “package”. - “cli” - plain text logs (for command-line tools) - “api” - json-line logs (for API services) - “package” - minimal setup for library use