|
5 years ago | |
---|---|---|
ext/journald_native | 5 years ago | |
lib/journald | 5 years ago | |
spec | 7 years ago | |
.gitignore | 5 years ago | |
.travis.yml | 7 years ago | |
COPYING.md | 7 years ago | |
LICENSE.md | 5 years ago | |
README.md | 5 years ago | |
Rakefile | 9 years ago | |
gems.rb | 5 years ago | |
journald-native.gemspec | 5 years ago |
README.md
journald-native
A systemd-journal native logging lib wrapper. See sd-journal help for more info
Installation
Run
gem install journald-native
or add
gem 'journald-native', '~> 1.0'
to your Gemfile.
Please note that you need a systemd development package installed in your system like systemd-devel
in Fedora, libsystemd-dev
in Debian, also may be a separate package for journal in older systems like libsystemd-journal-dev
.
NB: The gem can be installed on non-linux system but it will do nothing there. (Functions will return success without any actual effect)
Usage
require 'journald/native'
Constants
Constants are used to denote a log level
Available constants:
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,
e.g. Journald::LOG_WARNING == Syslog::LOG_WARNING
.
See syslog man page for more info
Methods
Methods of Journald::Native class wrap systemd-journal calls. See sd-journal help for more info
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 get exception if your string contains
'\0'
byte due to C zero-terminated string format. On the contrary send
uses binary buffers and
does not have this shortcoming.
License
The gem is available as open source under the terms of the GNU Lesser General Public License, version 2.1 or later.