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

Easily accessible logger infrastructure for Components and Modules #80

Closed
1 task done
Supereg opened this issue Aug 10, 2023 · 0 comments · Fixed by #98
Closed
1 task done

Easily accessible logger infrastructure for Components and Modules #80

Supereg opened this issue Aug 10, 2023 · 0 comments · Fixed by #98
Labels
enhancement New feature or request

Comments

@Supereg
Copy link
Member

Supereg commented Aug 10, 2023

Problem

Currently, every implementing Component is responsible to create and manage their instances of a Logger. This impose the following problems:

  • Creating a Logger is often times a multi-step process and could be considered tedious. This might result in developers not adopting at all or falling back to non-structured logging techniques like a simple print statement. Both goes against our aims of have maintainable and traceable code.
  • Developers might not have good guidance on what identifiers to choose (e.g., subsystem and category labels). This might result in choosing inconsistent identifiers.

Solution

This issue proposes a solution where Components or Modules can easily access a Logger instance that is tied to their specific implementation, such that:

  • It is easy to access.
  • It provides strong and consistent defaults for the logger subsystem and category.

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 the Spezi instance which provides the global default logger for the Spezi framework.

A potential solution to address this issue could be implementing some kind of @Logger property wrapper which can be used inside Component and Module implementations. The property wrapper would make use of the SpeziStorage repository to retrieve and store the logger instance, similar to the SpeziLogger 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 the Component?

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines
@Supereg Supereg added the enhancement New feature or request label Aug 10, 2023
@PSchmiedmayer PSchmiedmayer moved this to Backlog in Project Planning Sep 16, 2023
@Supereg Supereg linked a pull request Feb 18, 2024 that will close this issue
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).
@github-project-automation github-project-automation bot moved this from Backlog to Done in Project Planning Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant