Skip to content
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

change darwin impl to delegate to os_log_t #348

Merged
merged 6 commits into from
Aug 9, 2023
Merged

change darwin impl to delegate to os_log_t #348

merged 6 commits into from
Aug 9, 2023

Conversation

oshai
Copy link
Owner

@oshai oshai commented Aug 8, 2023

based on previous impl and https://blog.shipbook.io/ios-logs

looks like a better approach will be to just delegate logs to the os logger.

@oshai
Copy link
Owner Author

oshai commented Aug 8, 2023

@conradev following a refactoring around multiplatform I thought about simplifying darwin support.
As the author of the original PR #227 I would really appreciate to get your opinion.

This PR is changing darwin to behave more similar to other platforms that delegate logging to the native system. Major changes are:

  • console logging is not supported anymore by itself (as long as the os logging don't support that).
  • the resolution of subsystem and category was changed as follows:
    KotlinLoggingConfiguration contains two optional fields:
public object KotlinLoggingConfiguration {
  public var subsystem: AtomicReference<String?> = AtomicReference(null)
  public var category: AtomicReference<String?> = AtomicReference(null)
}
  • If both set they will be used as constant logger.
  • if one is set it will be used, and the configured logger name will be used as the other.
  • if both are null and logger name is empty OS_LOG_DEFAULT will be used.
  • lastly if name contains "." it will be split and the category will be the part after the dot.
  • and finally if name does not contain dot will result in blank category and logger name as subsystem.

The code can be seen in KLoggerFactory.

I would really appreciate any thought about the revised impl. If console logging is something often used we can consider of a way to have both the new impl and console logging (with a config to pick which is used). But most other platforms that have clear native logging don't have that.

Copy link
Contributor

@conradev conradev left a comment

Choose a reason for hiding this comment

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

This overall approach looks great to me! I am glad that it is more standard for the library. I only started with console appender because that is what the existing macOS support used and I didn't want to rock the boat

I noted a small bug, but besides that it looks great!

@conradev
Copy link
Contributor

conradev commented Aug 9, 2023

Next up, you should consider defaulting to journalctl on Linux if it is present if you don't already

@oshai
Copy link
Owner Author

oshai commented Aug 9, 2023

Next up, you should consider defaulting to journalctl on Linux if it is present if you don't already

Thanks for the quick review! Regarding linux, an initial contribution is welcome (mostly how to access the linux api) and I can take if from there if you would like.

@oshai oshai merged commit b1e8e8b into master Aug 9, 2023
9 checks passed
@oshai oshai deleted the mp_abstraction branch August 9, 2023 06:19
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.

2 participants