aboutsummaryrefslogtreecommitdiff
path: root/hsm-core/Hsm/Core/App.hs
blob: 11759bed1372e73891aa98beb5552d96ee380fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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