@@ -0,0 +1,46 @@
1+module Yoga.LoggerOm
2+ ( logInfo
3+ , logDebug
4+ , logWarn
5+ , logError
6+ ) where
7+
8+import Prelude
9+
10+import Effect.Class (liftEffect)
11+import Yoga.Logger (Logger)
12+import Yoga.Logger as Logger
13+import Prim.Row (class Lacks)
14+import Record as Record
15+import Type.Proxy (Proxy(..))
16+import Unsafe.Coerce (unsafeCoerce)
17+import Yoga.Om as Om
18+
19+-- Helper to convert record to Object String
20+recordToObjectString :: forall r. Record r -> Logger.LogContext
21+recordToObjectString = unsafeCoerce
22+
23+-- Om-specific logging functions that use the unified Logger interface
24+logInfo :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
25+logInfo 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)
29+
30+logDebug :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
31+logDebug 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)
35+
36+logWarn :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
37+logWarn 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)
41+
42+logError :: forall ctx logCtx err. Lacks "body" logCtx => String -> { | logCtx } -> Om.Om { logger :: Logger | ctx } err Unit
43+logError 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)