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

Allow overriding the logger in the controller context #1923

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

mpscholten
Copy link
Member

No description provided.

Copy link
Collaborator

@amitaibu amitaibu left a comment

Choose a reason for hiding this comment

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

Looks nicer than the other solution 👍

Let's add docs also on where/ how to put logger

-- The following hack is bad, but allows us to override the logger using 'putContext'
-- The alternative would be https://github.com/digitallyinduced/ihp/pull/1921 which is also not very nice
--
-- This design mistake should be fixed in IHP v2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, what's your idea for fixing on v2?

Copy link
Member Author

Choose a reason for hiding this comment

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

No specific idea yet. We kind of want to make controller context less mutable (e.g. we could change the type signature from initContext to the type signature of mapContext in the other branch. That way it's more functional, which would avoid this issue)

Comment on lines 146 to 147
getField context@(FrozenControllerContext { customFields }) = fromMaybe context.frameworkConfig.logger (TypeMap.lookup @Logger)
getField context = (unsafePerformIO (freeze context)).logger
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's worth adding some comment to what we're doing here -- it's not clear to me

Copy link
Member Author

Choose a reason for hiding this comment

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

Just added more comments, hope this clears it a bit

@mpscholten mpscholten merged commit 5f289b7 into master Mar 15, 2024
2 checks passed
@mpscholten mpscholten deleted the user-logger-alternative branch March 15, 2024 19:57
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