Currently, the tracing::subscriber::set_default function sets our custom subscriber as the default subscriber for the duration of the lifetime of the returned DefaultGuard value. However, it does not propagate the current thread's default subscriber to all threads because of which some log events (including Rust driver's logs) are not captured. To check that, run a simple test example with RUNTIME in lib.rs built with new_current_thread:
As the integration tests set a custom log callback, all logs from the test example will be written to a file in build/log/{TEST} directory which is not the case with a multithreaded environment.
One possible solution is to use the set_global_default function which will set the subscriber as default for all threads for the lifetime of the program. However, it can be called once and the subscriber cannot be changed later, for example, to change the log level during the runtime of the application. In fact, the C++ driver does not support dynamic configuration of logging, and the configuration must not be changed after any other driver function is called, e.g. cass_session_connect. So, the solution does not contradict to C++ driver's API requirements.
Unfortunately, I could not find a way to have a dynamic logging configuration with the current tracing_subscriber API, so if you have an idea to accomplish that, please share it in the scope of this issue.
Currently, the
tracing::subscriber::set_default
function sets our custom subscriber as the default subscriber for the duration of the lifetime of the returnedDefaultGuard
value. However, it does not propagate the current thread's default subscriber to all threads because of which some log events (including Rust driver's logs) are not captured. To check that, run a simple test example withRUNTIME
inlib.rs
built withnew_current_thread
:As the integration tests set a custom log callback, all logs from the test example will be written to a file in
build/log/{TEST}
directory which is not the case with a multithreaded environment.One possible solution is to use the
set_global_default
function which will set the subscriber as default for all threads for the lifetime of the program. However, it can be called once and the subscriber cannot be changed later, for example, to change the log level during the runtime of the application. In fact, the C++ driver does not support dynamic configuration of logging, and the configuration must not be changed after any other driver function is called, e.g.cass_session_connect
. So, the solution does not contradict to C++ driver's API requirements. Unfortunately, I could not find a way to have a dynamic logging configuration with the currenttracing_subscriber
API, so if you have an idea to accomplish that, please share it in the scope of this issue.