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
Currently, filterLogger :: (LogSource -> LogLevel -> Bool) -> LoggingT m a -> LoggingT m a. I'd like filterLogger :: MonadLogger m => (LogSource -> LogLevel -> Bool) -> m a -> m a.
Unfortunately, I can't see a way to do this without a breaking API change or a new typeclass.
Why do I want this? I have a function that's polymorphic on MonadLogger m, which invokes a library which has lots of log output. I'd like to silence some invocations of this library, but not others. I can do one of the following things:
Make LoggingT explicit in the type, losing polymorphism, and causing me to plumb this decision all the way through all the callers.
Create a new typeclass specifically for modifying the logger function.
If we're going for majorly breaking changes, I think we have better options at our disposal, specifically to model this as a MonadReader, together with a local method. The downside is that we either need to explicitly state the base monad (IO) or use a type family/fundep to establish it. Still, that feels much less ad-hoc than using a lens like this.
Currently,
filterLogger :: (LogSource -> LogLevel -> Bool) -> LoggingT m a -> LoggingT m a
. I'd likefilterLogger :: MonadLogger m => (LogSource -> LogLevel -> Bool) -> m a -> m a
.Unfortunately, I can't see a way to do this without a breaking API change or a new typeclass.
Why do I want this? I have a function that's polymorphic on
MonadLogger m
, which invokes a library which has lots of log output. I'd like to silence some invocations of this library, but not others. I can do one of the following things:The new typeclass could look something like this:
This would then allow polymorphic implementations of
filterLogger
andwithChannelLogger
.NoLoggingT
would get an improper lens, but I think that's ok.Personally, I'd prefer that this capability always be available to
MonadLogger
instances, but I realize the API breakage would be huge.Thoughts? Maybe something like this can make it into the next major-major release?
The text was updated successfully, but these errors were encountered: