bytelog 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+18/−2 lines, 3 files
Files
- CHANGELOG.md +4/−0
- bytelog.cabal +1/−1
- src/Logger.hs +13/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for bytelog +## 0.1.1.0 -- 2020-10-21++* Add `cstring#`.+ ## 0.1.0.0 -- 2020-03-09 * Initial release.
bytelog.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: bytelog-version: 0.1.0.0+version: 0.1.1.0 synopsis: Fast logging bug-reports: https://github.com/byteverse/bytelog license: BSD-3-Clause
src/Logger.hs view
@@ -15,6 +15,7 @@ , bytes , byteArray , cstring+ , cstring# -- * Flush , flush ) where@@ -30,7 +31,7 @@ import Data.Primitive (MutablePrimArray,ByteArray) import Foreign.C.Error (eINTR,eWOULDBLOCK,eAGAIN,eBADF) import Foreign.C.String (CString)-import GHC.Exts (RealWorld)+import GHC.Exts (Ptr(Ptr),RealWorld,Addr#) import GHC.IO (IO(IO)) import Posix.File (uninterruptibleWriteByteArray,uninterruptibleGetStatusFlags) import System.IO (Handle)@@ -106,6 +107,17 @@ -- | Log a @NUL@-terminated C string. cstring :: Logger -> CString -> IO () cstring g str = builder g (Builder.cstring str)++-- | Log a @NUL@-terminated C string. Takes the unboxed equivalent of @CString@.+-- This improves legibility in a common case:+--+-- > cstring logger (Ptr "Initializing..."#)+--+-- This can be written more succinctly as:+--+-- > cstring# logger "Initializing..."#+cstring# :: Logger -> Addr# -> IO ()+cstring# g str = builder g (Builder.cstring (Ptr str)) -- | Log the chunks that result from executing the byte builder. builder :: Logger -> Builder -> IO ()