packages feed

libsystemd-journal 1.3.4 → 1.4.0

raw patch · 3 files changed

+41/−10 lines, 3 files

Files

Changelog.md view
@@ -1,7 +1,12 @@+# 1.4.0++* Added the ability to read the journal backwards as well as forwards. Thanks to+  @defanor for this change.+ # 1.3.4  * Added the `journalEntryRealtime` property to `JournalEntry`s. This is backed by a call to-  `sd_journal_get_realtime_usec`.+  `sd_journal_get_realtime_usec`. Thanks to @rickynils for this change. * Build with `vector` < 0.12.  # 1.3.3
libsystemd-journal.cabal view
@@ -1,5 +1,5 @@ name:                libsystemd-journal-version:             1.3.4+version:             1.4.0 synopsis:            Haskell bindings to libsystemd-journal homepage:            http://github.com/ocharles/libsystemd-journal license:             BSD3
src/Systemd/Journal.hsc view
@@ -33,6 +33,7 @@       -- * Reading the journal     , openJournal     , Start(..)+    , Direction(..)     , JournalEntry, JournalEntryCursor     , journalEntryFields, journalEntryCursor, journalEntryRealtime     , JournalFlag (..)@@ -209,6 +210,9 @@ foreign import ccall "sd_journal_next"  sdJournalNext :: Ptr JournalEntry -> IO Int +foreign import ccall "sd_journal_previous"+ sdJournalPrevious :: Ptr JournalEntry -> IO Int+ foreign import ccall "sd_journal_add_match"  sdJournalAddMatch :: Ptr JournalEntry -> Ptr a -> #{type size_t} -> IO Int @@ -291,14 +295,24 @@   -- satisfy either condition.   deriving (Data, Eq, Show, Typeable) + --------------------------------------------------------------------------------+-- | In which direction to read the journal.+data Direction+  = Forwards+  -- ^ Read towards the end.+  | Backwards+  -- ^ Read towards the beginning.+  deriving (Eq)++-------------------------------------------------------------------------------- -- | Where to begin reading the journal from. data Start   = FromStart   -- ^ Begin reading from the start of the journal.-  | FromEnd+  | FromEnd Direction   -- ^ Begin reading from the end of the journal.-  | FromCursor JournalEntryCursor+  | FromCursor JournalEntryCursor Direction   -- ^ From a 'JournalEntryCursor'.  --------------------------------------------------------------------------------@@ -335,13 +349,15 @@       FromStart ->         return () -      FromEnd -> void $ do+      FromEnd d -> void $ do         throwIfNeg (("sd_journal_seek_tail: " ++) . show) $           sdJournalSeekTail journalPtr-        throwIfNeg (("sd_journal_previous_skip" ++) . show) $-          sdJournalPreviousSkip journalPtr 1+        when (d == Forwards) $ do+          throwIfNeg (("sd_journal_previous_skip" ++) . show) $+            sdJournalPreviousSkip journalPtr 1+          return () -      FromCursor cursor -> void $+      FromCursor cursor _ -> void $         BS.useAsCString cursor (sdJournalSeekCursor journalPtr)      _ <- throwIfNeg (("sd_journal_set_data_threshold returned: " ++) . show) .@@ -365,6 +381,16 @@      in addRule . Uniplate.transform cnf ++  sdJournalDirection :: Direction+  sdJournalDirection = case start of+    FromStart -> Forwards+    FromEnd d -> d+    FromCursor _ d -> d++  sdJournalMove :: Ptr JournalEntry -> IO Int+  sdJournalMove = if sdJournalDirection == Forwards then sdJournalNext else sdJournalPrevious+   go journalPtr = do     let readField =           alloca $ \dataPtrPtr ->@@ -393,7 +419,7 @@              Nothing -> return acc -    progressedBy <- liftIO (sdJournalNext journalPtr)+    progressedBy <- liftIO (sdJournalMove journalPtr)      case compare progressedBy 0 of       GT -> do@@ -411,7 +437,7 @@          go journalPtr -      EQ -> do+      EQ -> when (sdJournalDirection == Forwards) $ do         liftIO $ sdJournalWait journalPtr (-1)         go journalPtr