Git Product home page Git Product logo

journald-native's Introduction

journald-native

Build Status

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.11'

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.sd_journal_send "MESSAGE=message", "PRIORITY=#{Journald::LOG_WARNING}"
Journald::Native.sd_journal_print Journald::LOG_WARNING, "message"
Journald::Native.sd_journal_perror "message"

It is not recommended to use sd_journal_print and sd_journal_perror as you may get exception if your string contains '\0' byte due to C zero-terminated string format. On the contrary sd_journal_send uses binary buffers and does not have this shortcoming.

Short aliases

Versions prior to 1.0.11 used short function names that are available now as aliases. They will probably throw a deprecation warning in 1.1 and be removed in 2.0 should these versions ever happen.

Journald::Native.sd_journal_send can be called as Journald::Native.send
Journald::Native.sd_journal_print can be called as Journald::Native.print
Journald::Native.sd_journal_perror can be called as Journald::Native.perror

Please note that send method is overridden. This is a bad practice and a reason why longer names were introduced later

Authors

This library was written by Anton Smirnov and currently maintained by https://www.theforeman.org developers.

License

Copyright (c) 2014 Anton Smirnov

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You can find a copy of the GNU Lesser General Public License in COPYING.md or at https://www.gnu.org/licenses/lgpl-2.1.txt.

journald-native's People

Contributors

arokettu avatar lzap avatar mmoll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

journald-native's Issues

Can't install it on FreeBSD

I can't install it on FreeBSD 11.1-RELEASE-p4:

# gem install journald-native -v '1.0.10' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR:  Error installing journald-native:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.4/gems/journald-native-1.0.10/ext/journald_native
/usr/local/bin/ruby24 -r ./siteconf20180810-17968-eivwpi.rb extconf.rb
checking for systemd/sd-journal.h... no
checking for -lsystemd... no
checking for sd_journal_print()... no
checking for -lsystemd-journal... no
checking for sd_journal_print()... no
creating extconf.h
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.4/gems/journald-native-1.0.10/ext/journald_native
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.4/gems/journald-native-1.0.10/ext/journald_native
make "DESTDIR="
compiling journald_native.c
In file included from journald_native.c:21:
./sd_journal.h:60:10: warning: Compiling dummy version of the gem for non-Linux OS [-W#warnings]
        #warning Compiling dummy version of the gem for non-Linux OS
         ^
In file included from journald_native.c:21:
In file included from ./sd_journal.h:62:
./sd_journal_dummy.h:35:8: error: redefinition of 'iovec'
struct iovec {
       ^
/usr/include/sys/_iovec.h:43:8: note: previous definition is here
struct iovec {
       ^
1 warning and 1 error generated.
*** Error code 1

Stop.
make: stopped in /usr/local/lib/ruby/gems/2.4/gems/journald-native-1.0.10/ext/journald_native

make failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.4/gems/journald-native-1.0.10 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4/extensions/amd64-freebsd-11/2.4/journald-native-1.0.10/gem_make.out```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.