Safe Haskell | None |
---|
Systemd.Journal
Contents
- sendMessage :: Text -> IO ()
- sendMessageWith :: Text -> JournalFields -> IO ()
- sendJournalFields :: JournalFields -> IO ()
- type JournalFields = HashMap JournalField ByteString
- message :: Text -> JournalFields
- messageId :: UUID -> JournalFields
- priority :: Priority -> JournalFields
- data Priority
- codeFile :: FilePath -> JournalFields
- codeLine :: Int -> JournalFields
- codeFunc :: Text -> JournalFields
- errno :: Int -> JournalFields
- syslogFacility :: Facility -> JournalFields
- syslogIdentifier :: Text -> JournalFields
- syslogPid :: CPid -> JournalFields
- data JournalField
- mkJournalField :: Text -> JournalField
- openJournal :: MonadSafe m => [JournalFlag] -> Start -> Maybe Filter -> Producer' JournalEntry m ()
- data Start
- data JournalEntry
- type JournalEntryCursor = ByteString
- journalEntryFields :: JournalEntry -> JournalFields
- journalEntryCursor :: JournalEntry -> JournalEntryCursor
- data JournalFlag
- = LocalOnly
- | RuntimeOnly
- | SystemOnly
- data Filter
- = Match JournalField ByteString
- | And Filter Filter
- | Or Filter Filter
Writing to the journal
sendMessage :: Text -> IO ()
Send a message to the systemd journal.
sendMessage t == sendJournalFields (message t)
sendMessageWith :: Text -> JournalFields -> IO ()
Send a message and supply extra fields.
Note: The MESSAGE
field will be replaced with the first parameter to this
function. If you don't want this, use sendJournalFields
sendJournalFields :: JournalFields -> IO ()
Send an exact set of fields to the systemd journal.
type JournalFields = HashMap JournalField ByteString
A structured object of all the fields in an entry in the journal. You generally don't construct this yourself, but you use the monoid instance and smart constructors below.
For example,
sendJournalFields (message "Oh god, it burns!" <> priority Emergency)
Standard systemd journal fields
message :: Text -> JournalFields
The human readable message string for this entry. This is supposed to be the primary text shown to the user. It is usually not translated (but might be in some cases), and is not supposed to be parsed for meta data.
messageId :: UUID -> JournalFields
A 128bit message identifier ID for recognizing certain message types, if
this is desirable. Developers can generate a new ID for this purpose with
journalctl --new-id
.
priority :: Priority -> JournalFields
A priority value compatible with syslog's priority concept.
data Priority
Log messages are prioritized.
codeFile :: FilePath -> JournalFields
The source code file generating this message.
codeLine :: Int -> JournalFields
The source code line number generating this message.
codeFunc :: Text -> JournalFields
The source code function name generating this message.
errno :: Int -> JournalFields
The low-level Unix error number causing this entry, if any. Contains the
numeric value of errno(3)
.
syslogFacility :: Facility -> JournalFields
Syslog compatibility field.
syslogIdentifier :: Text -> JournalFields
Syslog compatibility field.
syslogPid :: CPid -> JournalFields
Syslog compatibility field.
Custom journal fields
data JournalField
mkJournalField :: Text -> JournalField
Construct a JournalField
by converting to uppercase, as required by the
journal.
Reading the journal
Arguments
:: MonadSafe m | |
=> [JournalFlag] | A list of flags taken under logical disjunction (or) to specify which journal files to open. |
-> Start | Where to begin reading journal entries from. |
-> Maybe Filter | An optional filter to apply the journal. Only entries satisfying the filter will be emitted. |
-> Producer' JournalEntry m () |
Opens the journal for reading, optionally filtering the journal entries. Filters are defined as arbitrary binary expression trees, which are then rewritten to be in conjunctive normal form before filtering with systemd to comply with systemd's rule system.
data Start
Where to begin reading the journal from.
Constructors
FromStart | Begin reading from the start of the journal. |
FromEnd | Begin reading from the end of the journal. |
FromCursor JournalEntryCursor | From a |
type JournalEntryCursor = ByteString
journalEntryFields :: JournalEntry -> JournalFields
A map of each JournalField
to its value.
journalEntryCursor :: JournalEntry -> JournalEntryCursor
A JournalCursor
can be used as marker into the journal stream. This can
be used to re-open the journal at a specific point in the future, and
JournalCursor
s can be serialized to disk.
data JournalFlag
Flags to specify which journal entries to read.
Constructors
LocalOnly | Only journal files generated on the local machine will be opened. |
RuntimeOnly | Only volatile journal files will be opened, excluding those which are stored on persistent storage. |
SystemOnly | Only journal files of system services and the kernel (in opposition to user session processes) will be opened. |
Instances
data Filter
A logical expression to filter journal entries when reading the journal.
Constructors
Match JournalField ByteString | A binary exact match on a given |
And Filter Filter | Logical conjunction of two filters. Will only show journal entries that satisfy both conditions. |
Or Filter Filter | Logical disjunction of two filters. Will show journal entries that satisfy either condition. |