git.iko.soy/rowtype-yoga/purescript-yoga-pino-om
on main help sign in
46 lines 1.9 kB history raw
1module Yoga.LoggerOm
2 ( logInfo
3 , logDebug
4 , logWarn
5 , logError
6 ) where
8import Prelude
10import Effect.Class (liftEffect)
11import Yoga.Logger (Logger)
12import Yoga.Logger as Logger
13import Prim.Row (class Lacks)
14import Record as Record
15import Type.Proxy (Proxy(..))
16import Unsafe.Coerce (unsafeCoerce)
17import Yoga.Om as Om
19-- Helper to convert record to Object String
20recordToObjectString :: forall r. Record r -> Logger.LogContext
21recordToObjectString = unsafeCoerce
23-- Om-specific logging functions that use the unified Logger interface
24logInfo :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
25logInfo message logCtx = do
26 { logger } <- Om.ask
27 let ctxWithBody = Record.insert (Proxy :: Proxy "body") message logCtx
28 liftEffect $ Logger.logInfo logger message (recordToObjectString ctxWithBody)
30logDebug :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
31logDebug message logCtx = do
32 { logger } <- Om.ask
33 let ctxWithBody = Record.insert (Proxy :: Proxy "body") message logCtx
34 liftEffect $ Logger.logDebug logger message (recordToObjectString ctxWithBody)
36logWarn :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
37logWarn message logCtx = do
38 { logger } <- Om.ask
39 let ctxWithBody = Record.insert (Proxy :: Proxy "body") message logCtx
40 liftEffect $ Logger.logWarn logger message (recordToObjectString ctxWithBody)
42logError :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
43logError message logCtx = do
44 { logger } <- Om.ask
45 let ctxWithBody = Record.insert (Proxy :: Proxy "body") message logCtx
46 liftEffect $ Logger.logError logger message (recordToObjectString ctxWithBody)