Fix logger synchronization: delegate Messenger logging to MidiCIDevice #26
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.
Fix Logger Synchronization Between Messenger and MidiCIDevice
Problem
The C++ Messenger implementation had its own separate
logger_that didn't synchronize with MidiCIDevice's logger, unlike the Kotlin implementation which properly delegates logging functionality from the device.As noted in PR #25 feedback:
Solution
This PR implements the delegation pattern to match the Kotlin implementation where
private val logger by device::loggerdelegates logging to the device.Changes Made
Added logger functionality to MidiCIDevice:
LoggerFunctiontypedef:std::function<void(const std::string&, bool)>set_logger(LoggerFunction logger)methodget_logger()method (like Kotlin'sgetLogger()function)Fixed Messenger to delegate to device logger:
logger_member from Messenger::Impllog_message()to usedevice_.get_logger()instead of own loggerMessenger::set_logger()method as it's no longer neededMaintains semantic logging format:
message.get_log_message()semantic formattingCode Changes
Before (Problematic)
After (Fixed Delegation)
Kotlin Reference Pattern
This matches the Kotlin implementation pattern:
Compatibility
Testing
Link to Devin run
https://app.devin.ai/sessions/24babee7bf4c453da6baef2f1e5f3ec8
Requested by
Atsushi Eno (atsushieno@gmail.com)