        errHandler e = do
            resources' <- loggerHandler resources e
            writeIORef resourcesRef resources'
    when (predicate pri) action `C.catch` errHandler

loggerHandler ::
       LoggerResources -> C.SomeException -> IO LoggerResources
loggerHandler resources e = do
    logError stdHandler "failed to use log file, error is:"
    logError stdHandler $ T.pack $ C.displayException e