Add native apis to change the log level via ICP#1439
Add native apis to change the log level via ICP#1439daneshk wants to merge 22 commits intoballerina-platform:masterfrom
Conversation
This change introduces Java APIs for the ICP agent to modify log levels at runtime without application restart. New features: - LogConfigManager.java: Singleton class providing Java APIs for ICP - getLogConfig(): Retrieve current log configuration - setGlobalLogLevel()/getGlobalLogLevel(): Root log level management - setModuleLevel()/removeModuleLevel(): Module-level configuration - setLoggerLevel(): Modify custom logger levels (user-named only) Custom logger identification: - Added optional 'id' field to Config record - Loggers with user-provided ID are visible to ICP and configurable - Loggers without ID get internal IDs and are not exposed to ICP Closes ballerina-platform/ballerina-library#6213 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds Java APIs to enable runtime log level modification via the ICP (Integrated Control Panel) agent. The implementation introduces a new LogConfigManager singleton class that manages log configuration state and provides thread-safe operations for dynamic log level changes. Custom loggers can now be assigned optional unique IDs to make them configurable at runtime through ICP.
Changes:
- Added
LogConfigManagerJava class for runtime log configuration management with thread-safe operations - Introduced optional
idfield toConfigrecord for creating ICP-visible custom loggers - Added test utilities and comprehensive test coverage for log configuration management APIs
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| native/src/main/java/io/ballerina/stdlib/log/LogConfigManager.java | Core implementation of singleton manager for runtime log level configuration with Java APIs for ICP integration |
| test-utils/src/main/java/io/ballerina/stdlib/log/testutils/nativeimpl/LogConfigTestUtils.java | Test utilities wrapper that exposes LogConfigManager APIs for testing purposes |
| ballerina/root_logger.bal | Updated logger implementation to support optional ID field and register loggers with LogConfigManager |
| ballerina/natives.bal | Added native function declarations for LogConfigManager interop |
| ballerina/init.bal | Initialize LogConfigManager with configurable values during module initialization |
| ballerina/tests/log_config_test.bal | Comprehensive test coverage for runtime log configuration APIs including global, module, and custom logger level management |
| integration-tests/tests/test_performance.bal | Performance comparison tests for logging with and without rotation |
| docs/spec/spec.md | Updated specification to document the new optional id field for loggers |
| docs/proposals/runtime_log_level_modification.md | Design proposal documenting the feature requirements, motivation, and API design |
| changelog.md | Added changelog entry for the new feature |
| build-config/spotbugs-exclude.xml | SpotBugs exclusions for intentional singleton pattern |
| ballerina/Ballerina.toml, Dependencies.toml, CompilerPlugin.toml | Version updates to 2.16.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
native/src/main/java/io/ballerina/stdlib/log/LogConfigManager.java
Outdated
Show resolved
Hide resolved
test-utils/src/main/java/io/ballerina/stdlib/log/testutils/nativeimpl/LogConfigTestUtils.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/log/LogConfigManager.java
Outdated
Show resolved
Hide resolved
…java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1439 +/- ##
============================================
+ Coverage 78.22% 80.67% +2.44%
- Complexity 97 132 +35
============================================
Files 9 10 +1
Lines 620 740 +120
Branches 116 127 +11
============================================
+ Hits 485 597 +112
- Misses 100 104 +4
- Partials 35 39 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Krishnananthalingam Tharmigan <63336800+TharmiganK@users.noreply.github.com>
Co-authored-by: Krishnananthalingam Tharmigan <63336800+TharmiganK@users.noreply.github.com>
|



Purpose
Fixes: ballerina-platform/ballerina-library#6213
This PR introduces Java APIs in LogConfigManager to support runtime log level modification via ICP. It also adds an optional id parameter to the fromConfig API to enable runtime log level changes for custom loggers.
Changes
Examples
Checklist