From cc639b06c7126fac7b445d8f778455620d7f8f50 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Sun, 29 Dec 2024 17:05:34 +0000 Subject: Initial --- hsm-core/Hsm/Core/App.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hsm-core/Hsm/Core/App.hs (limited to 'hsm-core/Hsm/Core/App.hs') 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 -- cgit v1.2.1