summaryrefslogtreecommitdiff
path: root/src/DPut.hs
diff options
context:
space:
mode:
authorjim@bo <jim@bo>2018-06-21 17:02:47 -0400
committerjim@bo <jim@bo>2018-06-21 17:02:47 -0400
commit217823867e3874cb4d3d8d619bc192aaf6c78028 (patch)
treea4225fa927137961ccae4a0e824f5aaf5a361814 /src/DPut.hs
parentf0f2bd11e0fc53ee0442dd110ff0a297716f1eda (diff)
DPut Trace Variations
tput - like dput, but works in any Applicative dtrace - like trace, but takes DebugTag
Diffstat (limited to 'src/DPut.hs')
-rw-r--r--src/DPut.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/DPut.hs b/src/DPut.hs
index 52714086..1b87eb93 100644
--- a/src/DPut.hs
+++ b/src/DPut.hs
@@ -27,6 +27,14 @@ dput tag msg = liftIO $ debugM (appName <.> show tag) msg
27dputB :: MonadIO m => DebugTag -> B.ByteString -> m () 27dputB :: MonadIO m => DebugTag -> B.ByteString -> m ()
28dputB tag msg = liftIO $ debugM (appName <.> show tag) (T.unpack . T.decodeUtf8 $ msg) 28dputB tag msg = liftIO $ debugM (appName <.> show tag) (T.unpack . T.decodeUtf8 $ msg)
29 29
30-- | Trace version of 'dput' works in arbitrary monad, using unsafePerformIO.
31tput :: Applicative m => DebugTag -> String -> m ()
32tput tag msg = (unsafePerformIO $ dput tag msg) `seq` pure ()
33
34-- | like 'trace' but parameterized with 'DebugTag'
35dtrace :: DebugTag -> String -> a -> a
36dtrace tag msg result = (unsafePerformIO $ dput tag msg) `seq` result
37
30setTagLevel :: Priority -> DebugTag -> IO () 38setTagLevel :: Priority -> DebugTag -> IO ()
31setTagLevel level tag = updateGlobalLogger (appName <.> show tag) (setLevel level) 39setTagLevel level tag = updateGlobalLogger (appName <.> show tag) (setLevel level)
32 40