scylladb / cpp-rust-driver

API-compatible rewrite of https://github.com/scylladb/cpp-driver as a wrapper for Rust driver.
GNU Lesser General Public License v2.1
16 stars 11 forks source link

Add tracing subscriber to enable logging #78

Closed Gor027 closed 1 year ago

Gor027 commented 2 years ago

Motivation:

Added tracing-subscriber crate to have one common way of logging with the Rust driver, as the Rust driver uses tracing crate for logging and cpp-rust driver should allow clients to configure logging by specifying the max log level and providing callback that should be called on each event.

Solution:

As logging should be configured globally, the current implementation creates a custom tracing subscriber with default configuration, which later can be changed by the user. The global and mutable state of the logging configuration is initialized in the lazy_static! block, however, it will be evaluated only after the first access in the code. As, the cass_session_new() function most probably is the first function that the user will call (almost all tests do that, too), the initialization of logging is chosen to be done in this function.

The CassLogMessage has a field function that should always be empty, as it cannot be properly set, because event metadata does not include information about it.

Enabled LoggingTests tests in github actions.

Pre-review checklist