-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging: propogate tracing subscriber for all threads #110
Labels
bug
Something isn't working
Comments
Gor027
added a commit
to Gor027/cpp-rust-driver
that referenced
this issue
Apr 26, 2023
Set default tracing subscriber globally for all threads for the duration of the entire program. This can be set only once, so subsequent attemps to set the log level through `cass_log_set_level` will be ignored. The logging configuration must be done before any other driver function is called, otherwise, the default logging callback will be used, and logs will appear on stderr. Fixes scylladb#110
5 tasks
Gor027
added a commit
to Gor027/cpp-rust-driver
that referenced
this issue
Apr 26, 2023
Set default tracing subscriber globally for all threads for the duration of the entire program. This can be set only once, so subsequent attemps to set the log level through `cass_log_set_level` will be ignored. The logging configuration must be done before any other driver function is called, otherwise, the default logging callback will be used, and logs will appear on stderr. Fixes scylladb#110
Gor027
added a commit
to Gor027/cpp-rust-driver
that referenced
this issue
Jun 11, 2023
Set default tracing subscriber globally for all threads for the duration of the entire program. This can be set only once, so subsequent attemps to set the log level through `cass_log_set_level` will be ignored. The logging configuration must be done before any other driver function is called, otherwise, the default logging callback will be used, and logs will appear on stderr. Fixes scylladb#110
syuu1228
pushed a commit
to syuu1228/cpp-rust-driver
that referenced
this issue
Apr 11, 2024
Set default tracing subscriber globally for all threads for the duration of the entire program. This can be set only once, so subsequent attemps to set the log level through `cass_log_set_level` will be ignored. The logging configuration must be done before any other driver function is called, otherwise, the default logging callback will be used, and logs will appear on stderr. Fixes scylladb#110
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 current
tracing_subscriber
API, so if you have an idea to accomplish that, please share it in the scope of this issue.The text was updated successfully, but these errors were encountered: