You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of right now there is no standard way to integrate logging capabilities into (reusable) SwiftUI views. While each view could just create their own Logger instance, this imposes the following problems:
Simple UI components which are part of something "bigger" have a hard time justifying their own Logger instance with their own subsystem and category labels. Ideally, they would just use the Logger instance provided from their environment.
The arguments discussed in the linked issue apply equally here.
Solution
This issue proposes a framework global loggerEnvironmentKey which provides a strong default for an app-global logger.
Using this environment key, Individual UI components can then easily decide if they (a) inject their own Logger instance for all of their subviews (e.g., providing better defaults for the whole app, or something like SpeziAccount would want to inject it's own logger for all of its subviews) or (b) use the Logger from the environment which is particularly useful for small, reusable UI components like the AsyncButton.
Additional context
A PR addressing this issue would ideally integrate the new logging principles into all views, where applicable, SpeziViews already provides.
Code of Conduct
I agree to follow this project's Code of Conduct and Contributing Guidelines
The text was updated successfully, but these errors were encountered:
Problem
This issue extends the discussion presented in StanfordSpezi/Spezi#80 to SwiftUI views.
As of right now there is no standard way to integrate logging capabilities into (reusable) SwiftUI views. While each view could just create their own
Logger
instance, this imposes the following problems:subsystem
andcategory
labels. Ideally, they would just use the Logger instance provided from their environment.Solution
This issue proposes a framework global
logger
EnvironmentKey which provides a strong default for an app-global logger.Using this environment key, Individual UI components can then easily decide if they (a) inject their own Logger instance for all of their subviews (e.g., providing better defaults for the whole app, or something like SpeziAccount would want to inject it's own logger for all of its subviews) or (b) use the Logger from the environment which is particularly useful for small, reusable UI components like the
AsyncButton
.Additional context
A PR addressing this issue would ideally integrate the new logging principles into all views, where applicable, SpeziViews already provides.
Code of Conduct
The text was updated successfully, but these errors were encountered: