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

[RFC] Allow arbitrary logger types #1736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ivanbakel
Copy link
Contributor

Intended to fix #1735.

This is a possible solution to allowing Yesod to support basically any kind of logging library, using an associated type family for the logger representation.

I don't know whether or not the existence of makeLogger and the passing of the logger to messageLoggerSource still make sense - a better design might simply be to rip them out entirely - but these changes should at least be backwards-compatible from an API standpoint.

Issues

This introduces a wedge between a Yesod site and the WAI server it runs on. The default logging middlewares that Yesod sets up will only accept Loggers, and since it's no longer possible to provide a Logger from the site type, a new one has to be created just to log from the middleware. That's a change in semantics that might surprise users. Additionally, some parts of middleware logging (like the exception logging in warp) still go through the Yesod site logger instead.

At the moment, all sites are tied to using the fast-logger `Logger` type
for Yesod's logging functions, including `makeLogger` and
`messageLoggerSource`. This represents an obstacle to logging through
other libraries which are incompatible with the fast-logger API.

This replaces the use of the concrete `Logger` type with an associated
type family on the `Yesod` class which allows sites to use their choice
of logger representation for Yesod's logging functions. The associated
type family is declared in such a way that existing instances should
work with no further effort.

This commit introduces a change in semantics around how logging is
shared between the Yesod site and the underlying WAI server - because
WAI is still tied to fast-logger, it's not possible to have them share
the logging config in general. Instead, the logger passed to WAI is the
default stdout logger.
@snoyberg snoyberg mentioned this pull request Aug 26, 2021
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.

Abstract Logging
1 participant