Skip to content

Configurable Logging #34

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

Merged
merged 12 commits into from
Apr 14, 2025
Merged

Configurable Logging #34

merged 12 commits into from
Apr 14, 2025

Conversation

stevensJourney
Copy link
Contributor

Overview

This adds the ability to specify a logger when creating a PowerSync database. The minimum log severity can be configured when creating a DefaultLogger.

Loggers also have the ability to specify custom LogWriters which can transport logs to custom sinks.

The implementation here declares a Swift logging interface and maps this to a Kotlin Kermit logger which is used internally.

@stevensJourney stevensJourney marked this pull request as ready for review April 8, 2025 08:22
@stevensJourney stevensJourney requested a review from Copilot April 8, 2025 08:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

stevensJourney and others added 5 commits April 8, 2025 10:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of making the loggers customizable, but I'm wondering why we're adding our own interfaces here instead of e.g. using https://github.com/apple/swift-log? We have to write a bridge from Kermit to something either way, so why not something that has an existing ecosystem with plenty of writer implementations around it? Do we need features that library doesn't support?

@stevensJourney
Copy link
Contributor Author

I'm in favor of making the loggers customizable, but I'm wondering why we're adding our own interfaces here instead of e.g. using https://github.com/apple/swift-log? We have to write a bridge from Kermit to something either way, so why not something that has an existing ecosystem with plenty of writer implementations around it? Do we need features that library doesn't support?

That's a fair point. My thinking here was to introduce a minimal interface with zero package dependencies. This keeps the core package lightweight and flexible. Users can opt for the default PrintLogger implementation or easily write adapters to integrate with their preferred logging library, including swift-log.

simolus3
simolus3 previously approved these changes Apr 8, 2025
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see 👍 In my humble opinion, using swift-log would make things easier for our users out of the box and reduce the code we have to write around defining logger APIs and printing to OSLog. But I understand the desire to not introduce dependencies either, and this approach looks good to me as well.

Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@stevensJourney stevensJourney merged commit 1d166f1 into main Apr 14, 2025
1 check passed
@stevensJourney stevensJourney deleted the logging branch April 14, 2025 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants