journalctl-stream 0.6.0.8 → 0.7.0.0
raw patch · 3 files changed
+44/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Systemd.Journalctl.Stream: Alert :: Priority
+ Systemd.Journalctl.Stream: Critical :: Priority
+ Systemd.Journalctl.Stream: Debug :: Priority
+ Systemd.Journalctl.Stream: Emergency :: Priority
+ Systemd.Journalctl.Stream: Error :: Priority
+ Systemd.Journalctl.Stream: Informational :: Priority
+ Systemd.Journalctl.Stream: Notice :: Priority
+ Systemd.Journalctl.Stream: Warning :: Priority
+ Systemd.Journalctl.Stream: [entryPriority] :: Entry -> Maybe Priority
+ Systemd.Journalctl.Stream: data Priority
+ Systemd.Journalctl.Stream: instance GHC.Classes.Eq Systemd.Journalctl.Stream.Priority
+ Systemd.Journalctl.Stream: instance GHC.Show.Show Systemd.Journalctl.Stream.Priority
- Systemd.Journalctl.Stream: Entry :: Maybe ProcessID -> Text -> Maybe Text -> Maybe Text -> Maybe FilePath -> Cursor -> POSIXTime -> Maybe Text -> Maybe (Either ByteString Text) -> Entry
+ Systemd.Journalctl.Stream: Entry :: Maybe ProcessID -> Text -> Maybe Text -> Maybe Text -> Maybe FilePath -> Cursor -> POSIXTime -> Maybe Text -> Maybe (Either ByteString Text) -> Maybe Priority -> Entry
- Systemd.Journalctl.Stream: entryStream :: (MonadResource m, MonadThrow m) => StreamStart -> ConduitT i Entry m ()
+ Systemd.Journalctl.Stream: entryStream :: forall (m :: Type -> Type) i. (MonadResource m, MonadThrow m) => StreamStart -> ConduitT i Entry m ()
Files
- changelog.md +3/−0
- journalctl-stream.cabal +3/−3
- lib/Systemd/Journalctl/Stream.hs +38/−1
changelog.md view
@@ -1,3 +1,6 @@+## 0.7.0.0+* Add support for priorities in journal entries.+ ## 0.6.0.8 * Metadata and documentation update.
journalctl-stream.cabal view
@@ -2,7 +2,7 @@ category: System synopsis: Stream logs using journalctl. description: Stream logs using journalctl. Check the documentation for more details.-version: 0.6.0.8+version: 0.7.0.0 author: Daniel Casanueva (coding `at` danielcasanueva.eu) maintainer: Daniel Casanueva (coding `at` danielcasanueva.eu) bug-reports: https://codeberg.org/daniel-casanueva/journalctl-stream/issues@@ -15,8 +15,8 @@ library hs-source-dirs: lib default-language: Haskell2010- default-extensions: ImportQualifiedPost, OverloadedStrings+ default-extensions: ImportQualifiedPost, OverloadedStrings, NumericUnderscores ghc-options: -Wall -Wunused-packages- build-depends: base < 4.21, conduit, process, text, time, bytestring+ build-depends: base < 4.23, conduit, process, text, time, bytestring , aeson >= 2.0 exposed-modules: Systemd.Journalctl.Stream
lib/Systemd/Journalctl/Stream.hs view
@@ -11,6 +11,7 @@ -- * Journal entry Entry (..) , Cursor+ , Priority (..) -- * Streaming , StreamStart (..) , entryStream@@ -63,6 +64,37 @@ instance ToJSON Cursor where toJSON (Cursor t) = JSON.String t +-- | Priority levels. See: https://www.rfc-editor.org/info/rfc5424/#section-6.2.1+data Priority =+ -- | System is unusable.+ Emergency+ -- | Action must be taken immediately.+ | Alert+ -- | Critical conditions.+ | Critical+ -- | Error conditions.+ | Error+ -- | Warning conditions.+ | Warning+ -- | Normal but significant condition.+ | Notice+ -- | Informational messages.+ | Informational+ -- | Debug-level messages.+ | Debug+ deriving (Eq, Show)++toPriority :: Int -> Maybe Priority+toPriority 0 = Just Emergency+toPriority 1 = Just Alert+toPriority 2 = Just Critical+toPriority 3 = Just Error+toPriority 4 = Just Warning+toPriority 5 = Just Notice+toPriority 6 = Just Informational+toPriority 7 = Just Debug+toPriority _ = Nothing+ -- | A journal entry. data Entry = Entry { -- | Process ID.@@ -83,6 +115,8 @@ , entryUnit :: Maybe Text -- | Entry message. It may come in binary or textual format. , entryMessage :: Maybe (Either ByteString Text)+ -- | Priority level.+ , entryPriority :: Maybe Priority } deriving Show -- | Utility type to parse values (mainly numbers) that are received@@ -109,9 +143,12 @@ <*> o .:? "_COMM" <*> o .:? "_EXE" <*> o .: "__CURSOR"- <*> (secondsToNominalDiffTime . (/1000000) . asText <$> o .: "__REALTIME_TIMESTAMP")+ <*> (secondsToNominalDiffTime . (/1_000_000) . asText <$> o .: "__REALTIME_TIMESTAMP") <*> o .:? "UNIT" <*> messageParser o+ <*> (do m <- o .:? "PRIORITY"+ pure $ m >>= toPriority . asText+ ) messageParser :: JSON.Object -> JSON.Parser (Maybe (Either ByteString Text)) messageParser obj =