-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Easily accessible logger infrastructure for Components and Modules #80
Labels
enhancement
New feature or request
Comments
1 task
1 task
1 task
PSchmiedmayer
pushed a commit
that referenced
this issue
Feb 19, 2024
…ort (#98) # Platform support, Application property wrapper and notifications support ## ♻️ Current situation & Problem Currently, the Core Spezi infrastructure is only developed for iOS. However, we are aiming to support Spezi on all Apple platforms. This step required to reengineer some Spezi infrastructure that was heavily tailored towards the iOS platform (e.g., the `LifecycleHandler`). This PR deprecates the `LifecycleHandler` in favor of using SwiftUI native approaches like the [`ScenePhase`](https://developer.apple.com/documentation/swiftui/scenephase) environment property or platform-specific publisher-based solutions like [`willEnterForegroundNotification`](https://developer.apple.com/documentation/uikit/uiscene/3197925-willenterforegroundnotification). Further we introduce the new `@Application` property wrapper for `Modules` and the `Standard` to access application-specific properties like `launchOptions`. Based on the new `@Application` infrastructure we resolve issues like #80 to provide Modules with Module-specific Logger instances. To further validate our `@Application` approach, we added infrastructure around (Remote Push) Notifications. You can use `@Application` to trigger application actions like `registerRemoteNotifications` or `unregisterRemoteNotifications` and additionally adopt protocols like `NotificationTokenHandler` and `NotificationHandler` to react to notification actions, control how notifications are delivered in foreground or fetch additional content for background notifications. ## ⚙️ Release Notes * Add support for visionOS, tvOS, watchOS and macOS. * Deprecated the `LifecycleHandler` protocol. * Added new `@Application` property wrapper to access application properties and actions in a a platform-agnostic way. * New protocol `NotificationTokenHandler` and `NotificationHandler` to easily support notification handling within your apps. ## 📚 Documentation There are two new articles `Interactions with Application` and `User Notifications` that provide an overview for those new infrastructure elements. ## ✅ Testing _TBA_ ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Currently, every implementing
Component
is responsible to create and manage their instances of aLogger
. This impose the following problems:print
statement. Both goes against our aims of have maintainable and traceable code.subsystem
andcategory
labels). This might result in choosing inconsistent identifiers.Solution
This issue proposes a solution where
Component
s orModule
s can easily access a Logger instance that is tied to their specific implementation, such that:subsystem
andcategory
.Ultimately we want to encourage increased usage of log message such that we have maintainable code that is easy to debug.
Additional context
For some context, we currently have the internal
SpeziLogger
KnowledgeSource stored inside the SharedRepository of theSpezi
instance which provides the global default logger for theSpezi
framework.A potential solution to address this issue could be implementing some kind of
@Logger
property wrapper which can be used insideComponent
andModule
implementations. The property wrapper would make use of theSpeziStorage
repository to retrieve and store the logger instance, similar to theSpeziLogger
knowledge source.One might need to think what challenges this design creates. How easy is it for the
Component
to pass around the Logger to other types which are created and managed by theComponent
?Code of Conduct
The text was updated successfully, but these errors were encountered: