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 SwiftUI views #9

Open
1 task done
Supereg opened this issue Aug 10, 2023 · 0 comments
Open
1 task done

Easily accessible logger infrastructure for SwiftUI views #9

Supereg opened this issue Aug 10, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Supereg
Copy link
Member

Supereg commented Aug 10, 2023

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:

  • 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 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

  • 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 Feb 22, 2024
@PSchmiedmayer PSchmiedmayer added the good first issue Good for newcomers label Feb 22, 2024
@pauljohanneskraft pauljohanneskraft self-assigned this May 7, 2024
@pauljohanneskraft pauljohanneskraft moved this from Backlog to In Progress in Project Planning May 7, 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 good first issue Good for newcomers
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants