Conversation
| (`local` unlift action) $ \logEnv -> logEnv { leDomain = leDomain logEnv ++ [domain] } | ||
| LocalMaxLogLevel level action -> localSeqUnlift env $ \unlift -> do | ||
| (`local` unlift action) $ \logEnv -> logEnv { leMaxLogLevel = level } | ||
| GetLoggerEnv -> ask) . handle logException |
There was a problem hiding this comment.
Use withException instead of handle (needs effectful-core-2.6.0.0).
| , module Log | ||
| ) where | ||
|
|
||
| import Control.Exception.Lifted |
There was a problem hiding this comment.
You can use Effectful.Exception.
| time <- liftIO getCurrentTime | ||
| logEnv <- getLoggerEnv | ||
| liftIO $ | ||
| logMessageIO logEnv time LogAttention "Uncaught exception" $ object ["error" .= (pack . show $ e)] |
There was a problem hiding this comment.
You can use logAttention here (and you don't need pack, same as in the log-base PR).
| (`local` unlift action) $ \logEnv -> logEnv { leMaxLogLevel = level } | ||
| GetLoggerEnv -> ask | ||
| runLog component logger maxLogLevel = | ||
| reinterpret reader (\env -> \case |
There was a problem hiding this comment.
Hmm, I think putting the handler in the where clause will be better for readability - right now it's somewhat hard to see the "handle" stuff at the end.
| logEnv <- getLoggerEnv | ||
| liftIO $ | ||
| logMessageIO logEnv time LogAttention "Uncaught exception" $ object ["error" .= (pack . show $ e)] | ||
| throw e |
|
Ah, also needs a bump to 1.2.0.0 and a changelog entry. |
mmhat
left a comment
There was a problem hiding this comment.
Hm, I think I'd prefer if we could leave the original runLog as it is now and introduce a new runLogWithException (or something like that) that logs uncaught exceptions:
runLogWithException component logger maxLevel = runLog component logger maxLevel . handle logException
|
Why? 🤔 |
It's not a strong argument, but I expect the |
Add an ultimate log if an uncaught exception interrupt the effects being run.