diff options
Diffstat (limited to 'hsm-core/Hsm/Core/App.hs')
-rw-r--r-- | hsm-core/Hsm/Core/App.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hsm-core/Hsm/Core/App.hs b/hsm-core/Hsm/Core/App.hs new file mode 100644 index 0000000..11759be --- /dev/null +++ b/hsm-core/Hsm/Core/App.hs @@ -0,0 +1,21 @@ +module Hsm.Core.App + ( launch + ) where + +import Data.Aeson (FromJSON) +import Data.Text (Text) +import Effectful.Log (LogLevel, Logger) +import Hsm.Core.Env (environment) +import Hsm.Core.Options (Options(Options), options) +import Log.Backend.StandardOutput (withStdOutLogger) + +launch :: + FromJSON env + => Text + -> (IO app -> IO app) + -> (env -> Logger -> LogLevel -> IO app) + -> IO app +launch name wrapper app = do + Options path level <- options name + env <- environment name path + wrapper $ withStdOutLogger $ \logger -> app env logger level |