diff options
author | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-05-29 16:07:59 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-05-29 16:07:59 -0500 |
commit | 8a06c083fab9c66e754c7ed5a75dd4d89131c43e (patch) | |
tree | 28098c165bce0d8ebb5dda2d5390e63ddca1ab1e /src/Tomato/App.hs | |
parent | 399ab3ee1653bbc0da69e2cc299aa2a313e765b4 (diff) |
Improve error reporting
Diffstat (limited to 'src/Tomato/App.hs')
-rw-r--r-- | src/Tomato/App.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Tomato/App.hs b/src/Tomato/App.hs new file mode 100644 index 0000000..14bf61a --- /dev/null +++ b/src/Tomato/App.hs @@ -0,0 +1,32 @@ +module Tomato.App + ( App (..) + , runApp + ) where + +import RIO + + +data App = App + { appLogFunc :: !LogFunc + , appToken :: !ByteString + , appBotId :: !Text + , appFile :: !FilePath + , appClientId :: !Text + } + +instance HasLogFunc App where + logFuncL = lens appLogFunc (\x y -> x { appLogFunc = y }) + +runApp :: RIO App a -> IO a +runApp inner = do + logOptions' <- logOptionsHandle stderr False + let logOptions = setLogUseTime True $ setLogUseLoc True logOptions' + withLogFunc logOptions $ \logFunc -> do + let app = App + { appLogFunc = logFunc + , appToken = "t2YhlxxwZmn2cWfkAomjMc6BgVPMaC5NRkqHzGQl" + , appBotId = "713bcb4a4604006c944804552c" + , appFile = "tomato.png" + , appClientId = "FbzqI-oR7277JwL1ZGsyUw7yG1F5U0U3WhQ3kOW71Do" + } + runRIO app inner |