|
|
|
@ -8,7 +8,7 @@ A systemd-journal native logging lib wrapper.
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
|
require 'journald/native'
|
|
|
|
|
require 'journald/native'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Constants
|
|
|
|
@ -18,14 +18,14 @@ Constants are used to denote a log level
|
|
|
|
|
Available constants:
|
|
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
|
Journald::LOG_EMERG # system is unusable
|
|
|
|
|
Journald::LOG_ALERT # action must be taken immediately
|
|
|
|
|
Journald::LOG_CRIT # critical conditions
|
|
|
|
|
Journald::LOG_ERR # error conditions
|
|
|
|
|
Journald::LOG_WARNING # warning conditions
|
|
|
|
|
Journald::LOG_NOTICE # normal but significant condition
|
|
|
|
|
Journald::LOG_INFO # informational
|
|
|
|
|
Journald::LOG_DEBUG # debug-level messages
|
|
|
|
|
Journald::LOG_EMERG # system is unusable
|
|
|
|
|
Journald::LOG_ALERT # action must be taken immediately
|
|
|
|
|
Journald::LOG_CRIT # critical conditions
|
|
|
|
|
Journald::LOG_ERR # error conditions
|
|
|
|
|
Journald::LOG_WARNING # warning conditions
|
|
|
|
|
Journald::LOG_NOTICE # normal but significant condition
|
|
|
|
|
Journald::LOG_INFO # informational
|
|
|
|
|
Journald::LOG_DEBUG # debug-level messages
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
systemd-journal uses syslog constants to denote level therefore they are equal to those of the Syslog module,
|
|
|
|
@ -38,14 +38,14 @@ Methods of Journald::Native class wrap systemd-journal calls.
|
|
|
|
|
[See sd-journal help for more info](http://www.freedesktop.org/software/systemd/man/sd_journal_print.html)
|
|
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
|
Journald::Native.send "MESSAGE=message", "PRIORITY=#{Journald::LOG_WARNING}"
|
|
|
|
|
Journald::Native.print Journald::LOG_WARNING, "message"
|
|
|
|
|
Journald::Native.perror "message"
|
|
|
|
|
Journald::Native.send "MESSAGE=message", "PRIORITY=#{Journald::LOG_WARNING}"
|
|
|
|
|
Journald::Native.print Journald::LOG_WARNING, "message"
|
|
|
|
|
Journald::Native.perror "message"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
It is not recommended to use ```print``` and ```perror``` as you may lose ```'\0'``` byte in your string due to
|
|
|
|
|
C zero-terminated string format (all zero bytes in the middle will be removed) On the contrary ```send``` uses
|
|
|
|
|
binary buffers and does not have such shortcoming.
|
|
|
|
|
binary buffers and does not have this shortcoming.
|
|
|
|
|
|
|
|
|
|
### License
|
|
|
|
|
|
|
|
|
|