{-# LANGUAGE RankNTypes #-}
module Di.Df1
( Df1
, push
, attr
, debug
, info
, notice
, warning
, error
, alert
, critical
, emergency
, debug'
, info'
, notice'
, warning'
, error'
, alert'
, critical'
, emergency'
, df1
, fromDiLog
, fromDf1Log
) where
import Control.Concurrent.STM (STM)
import Control.Monad.IO.Class (MonadIO)
import Prelude hiding (error)
import Unsafe.Coerce (unsafeCoerce)
import qualified Di.Core as Di (Di, Log(Log), log, log', push)
import qualified Di.Handle as Di (LineRenderer(LineRendererUtf8))
import qualified Df1
type Df1 = Di.Di Df1.Level Df1.Path Df1.Message
push
:: Df1.Segment
-> Di.Di level Df1.Path msg
-> Di.Di level Df1.Path msg
push s = Di.push (Df1.Push s)
{-# INLINE push #-}
attr
:: Df1.Key
-> Df1.Value
-> Di.Di level Df1.Path msg
-> Di.Di level Df1.Path msg
attr k v = Di.push (Df1.Attr k v)
{-# INLINE attr #-}
emergency
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
emergency di = Di.log di Df1.Emergency
{-# INLINE emergency #-}
alert
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
alert di = Di.log di Df1.Alert
{-# INLINE alert #-}
critical
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
critical di = Di.log di Df1.Critical
{-# INLINE critical #-}
error
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
error di = Di.log di Df1.Error
{-# INLINE error #-}
warning
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
warning di = Di.log di Df1.Warning
{-# INLINE warning #-}
notice
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
notice di = Di.log di Df1.Notice
{-# INLINE notice #-}
info
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
info di = Di.log di Df1.Info
{-# INLINE info #-}
debug
:: MonadIO m
=> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
debug di = Di.log di Df1.Debug
{-# INLINE debug #-}
emergency'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
emergency' natSTM di = Di.log' natSTM di Df1.Emergency
{-# INLINE emergency' #-}
alert'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
alert' natSTM di = Di.log' natSTM di Df1.Alert
{-# INLINE alert' #-}
critical'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
critical' natSTM di = Di.log' natSTM di Df1.Critical
{-# INLINE critical' #-}
error'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
error' natSTM di = Di.log' natSTM di Df1.Error
{-# INLINE error' #-}
warning'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
warning' natSTM di = Di.log' natSTM di Df1.Warning
{-# INLINE warning' #-}
notice'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
notice' natSTM di = Di.log' natSTM di Df1.Notice
{-# INLINE notice' #-}
info'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
info' natSTM di = Di.log' natSTM di Df1.Info
{-# INLINE info' #-}
debug'
:: Monad m
=> (forall x. STM x -> m x)
-> Di.Di Df1.Level path Df1.Message
-> Df1.Message
-> m ()
debug' natSTM di = Di.log' natSTM di Df1.Debug
{-# INLINE debug' #-}
df1 :: Di.LineRenderer Df1.Level Df1.Path Df1.Message
{-# INLINE df1 #-}
df1 = Di.LineRendererUtf8 (\x ->
if x then Df1.renderColor . fromDiLog
else Df1.render . fromDiLog)
fromDiLog :: Di.Log Df1.Level Df1.Path Df1.Message -> Df1.Log
{-# INLINE fromDiLog #-}
fromDiLog = unsafeCoerce
_fromDiLog :: Di.Log Df1.Level Df1.Path Df1.Message -> Df1.Log
_fromDiLog (Di.Log a b c d) = Df1.Log a b c d
fromDf1Log :: Df1.Log -> Di.Log Df1.Level Df1.Path Df1.Message
{-# INLINE fromDf1Log #-}
fromDf1Log = unsafeCoerce
_fromDf1Log :: Df1.Log -> Di.Log Df1.Level Df1.Path Df1.Message
_fromDf1Log (Df1.Log a b c d) = Di.Log a b c d