systemd-journal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/systemd-journal.rb +46 -0
  2. metadata +57 -0
@@ -0,0 +1,46 @@
1
+ module Systemd
2
+ module Journal
3
+
4
+ module FFI
5
+ require 'ffi'
6
+ extend ::FFI::Library
7
+ ffi_lib %w[libsystemd-journal.so libsystemd-journal.so.0]
8
+
9
+ attach_function :sd_journal_print, [:int, :string], :int
10
+ attach_function :sd_journal_send, [:varargs], :int
11
+
12
+ def self.to_string_varargs(arr)
13
+ varargs = []
14
+
15
+ arr.each do |entry|
16
+ varargs << :string
17
+ varargs << entry
18
+ end
19
+
20
+ varargs << :string
21
+ varargs << nil
22
+ end
23
+ end
24
+
25
+ # log levels
26
+ LOG_EMERG = 0
27
+ LOG_ALERT = 1
28
+ LOG_CRIT = 2
29
+ LOG_ERR = 3
30
+ LOG_WARNING = 4
31
+ LOG_NOTICE = 5
32
+ LOG_INFO = 6
33
+ LOG_DEBUG = 7
34
+
35
+ def self.print(level, message)
36
+ FFI::sd_journal_print(level, message)
37
+ end
38
+
39
+ def self.message(details = {})
40
+ arr = details.collect { |k,v| "#{k}=#{v}" }
41
+ varargs = FFI::to_string_varargs(arr)
42
+ FFI::sd_journal_send(*varargs)
43
+ end
44
+
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: systemd-journal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Mack
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffi
16
+ requirement: &22132540 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.11
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *22132540
25
+ description: This gem allows Ruby programs to interfact with the journal,
26
+ email:
27
+ - systemd@zonque.org
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - lib/systemd-journal.rb
33
+ homepage: http://github.com/zonque/systemd-journal.gem
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.10
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Ruby interface for systemds journal
57
+ test_files: []