diff options
author | jim@bo <jim@bo> | 2018-06-21 17:02:47 -0400 |
---|---|---|
committer | jim@bo <jim@bo> | 2018-06-21 17:02:47 -0400 |
commit | 217823867e3874cb4d3d8d619bc192aaf6c78028 (patch) | |
tree | a4225fa927137961ccae4a0e824f5aaf5a361814 /src/DPut.hs | |
parent | f0f2bd11e0fc53ee0442dd110ff0a297716f1eda (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.hs | 8 |
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 | |||
27 | dputB :: MonadIO m => DebugTag -> B.ByteString -> m () | 27 | dputB :: MonadIO m => DebugTag -> B.ByteString -> m () |
28 | dputB tag msg = liftIO $ debugM (appName <.> show tag) (T.unpack . T.decodeUtf8 $ msg) | 28 | dputB 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. | ||
31 | tput :: Applicative m => DebugTag -> String -> m () | ||
32 | tput tag msg = (unsafePerformIO $ dput tag msg) `seq` pure () | ||
33 | |||
34 | -- | like 'trace' but parameterized with 'DebugTag' | ||
35 | dtrace :: DebugTag -> String -> a -> a | ||
36 | dtrace tag msg result = (unsafePerformIO $ dput tag msg) `seq` result | ||
37 | |||
30 | setTagLevel :: Priority -> DebugTag -> IO () | 38 | setTagLevel :: Priority -> DebugTag -> IO () |
31 | setTagLevel level tag = updateGlobalLogger (appName <.> show tag) (setLevel level) | 39 | setTagLevel level tag = updateGlobalLogger (appName <.> show tag) (setLevel level) |
32 | 40 | ||