{-# LANGUAGE OverloadedStrings #-}

{- Defines a few internal functions for logging requests and responses in debug mode -}
module Pulsar.Internal.Logger where

import           Control.Logging                ( debug' )
import           Control.Monad.IO.Class         ( MonadIO )
import qualified Data.Text                     as T

logRequest :: (MonadIO m, Show a) => a -> m ()
logRequest :: a -> m ()
logRequest cmd :: a
cmd = Text -> m ()
forall (m :: * -> *). MonadIO m => Text -> m ()
debug' (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ ">>> " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (a -> String
forall a. Show a => a -> String
show a
cmd)

logResponse :: (MonadIO m, Show a) => a -> m ()
logResponse :: a -> m ()
logResponse cmd :: a
cmd = Text -> m ()
forall (m :: * -> *). MonadIO m => Text -> m ()
debug' (Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ "<<< " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (a -> String
forall a. Show a => a -> String
show a
cmd)