Package
- couchbase.configure_logging(name: str, level: int = 20, parent_logger: Logger | None = None) None
Configure the Python SDK to route the native core’s logs through Python’s logging system.
This is the programmatic alternative to using PYCBC_LOG_LEVEL environment variable. It allows integration with your application’s existing logging configuration.
Note: This configures the native core’s logs only. Python-side SDK components (threshold logging, metrics, transactions) use separate loggers under the ‘couchbase’ hierarchy.
To also capture threshold logging reports and other Python SDK logs, configure the ‘couchbase’ logger:
Example
import logging from couchbase import configure_logging
# Route the native core’s logs through Python configure_logging(‘my_app’, level=logging.DEBUG)
# Also capture Python SDK logs (threshold, metrics, transactions, etc.) couchbase_logger = logging.getLogger(‘couchbase’) couchbase_logger.addHandler(your_handler) couchbase_logger.setLevel(logging.INFO)
- Parameters:
name – Name for the logger
level – Python logging level (default: logging.INFO)
parent_logger – Optional parent logger
- Raises:
RuntimeError – If PYCBC_LOG_LEVEL environment variable is already set. Cannot use both configuration methods simultaneously.
- couchbase.enable_protocol_logger_to_save_network_traffic_to_file(filename: str) None
VOLATILE This API is subject to change at any time.
Exposes the underlying couchbase++ library protocol logger. This method is for logging/debugging purposes and must be used with caution as network details will be logged to the provided file.
A call made before the native core has loaded is held, and takes effect when it loads. A loaded protocol that has no protocol logger logs a warning.
- Parameters:
filename (str) – The name of the file the protocol logger will write to.
- Raises:
InvalidArgumentException – If the filename is not a non-empty string without a NUL character.
- couchbase.get_metadata(as_str: Literal[False] = False, detailed: bool = False) dict[str, Any]
- couchbase.get_metadata(as_str: Literal[True], detailed: bool = False) str
- couchbase.get_metadata(as_str: bool = False, detailed: bool = False) dict[str, Any] | str
Get metadata about the C++ client library.