Add log stream and callback to constructor#222
Conversation
This commit introduces the ability to pass an external logger function to the KomodoDefiSdk, allowing for custom logging of framework messages. Co-authored-by: charl <charl@vanstaden.info>
|
Cursor Agent can help with this pull request. Just |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR adds logging capabilities to the KomodoDefiSdk by exposing its log stream and adding an optional onLog callback parameter to both constructor methods.
- Adds an optional
onLogcallback parameter to both SDK constructors for external log handling - Exposes a public
logStreamgetter that provides access to framework logs - Manages log subscription lifecycle by properly disposing of the subscription when the SDK is disposed
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/komodo_defi_sdk/lib/src/komodo_defi_sdk.dart | Adds onLog callback parameter to constructors, implements log stream subscription management, and exposes public logStream getter |
| packages/komodo_defi_sdk/lib/src/bootstrap.dart | Updates bootstrap function to accept and use external logger callback for framework creation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (_kdfFramework != null && _onLog != null) { | ||
| _logSubscription = _kdfFramework!.logStream.listen(_onLog!); | ||
| } |
There was a problem hiding this comment.
This creates a log subscription only when _kdfFramework is provided in the constructor, but when using the default constructor, the framework is created later during initialization. This means the log subscription will never be established for the default constructor case.
| Stream<String> get logStream => _assertSdkInitialized( | ||
| _container<KomodoDefiFramework>().logStream, | ||
| ); |
There was a problem hiding this comment.
The logStream getter accesses the framework through the container, but there's no guarantee that the log subscription is properly established for all initialization paths. Consider adding logic in the initialization process to ensure the log subscription is created when needed.
|
@cursor fix the PR comments |
|
I refactored the logging mechanism within
Learn more about Cursor Agents |
Co-authored-by: charl <charl@vanstaden.info>
Expose
KomodoDefiSdklog stream and add an optionalonLogcallback to its constructors to allow external log handling.