Add log level resetting functionality for FFI #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements log level resetting functionality for FFI as requested in issue #12. The solution uses
tracing_subscriber::reload::Handle
with a global lazy static handle to provide dynamic log level management.Key Features
once_cell::Lazy
withMutex<Option<reload::Handle>>
to store the reload handle globallyset_log_level()
andreset_log_level()
allow runtime log level changesImplementation Details
New FFI Functions
set_log_level(level: *const c_char) -> bool
: Sets log level to specified string (e.g., "trace", "debug", "info", "warn", "error")reset_log_level() -> bool
: Resets log level to "trace" (maximum verbosity)Dependencies Updated
tracing-subscriber
to version 0.3.18 (provides reload functionality)once_cell
1.19 for thread-safe lazy static initializationCore Changes
setup_shared_logger()
to use reloadable filter withreload::Layer
RELOAD_HANDLE
static variable for handle managementRegistry
with layered architectureTest Coverage
Added comprehensive tests covering:
Usage Example
Technical Notes
The implementation avoids the issues mentioned in the original issue regarding generic types in statics by using a type-erased approach with
Box<dyn>
andonce_cell::Lazy
instead of rawlazy_static
. This provides a clean, thread-safe solution that works with the current tracing ecosystem.🤖 Generated with Claude Code
Fixes #12