systemd-journal 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0438540edec22fbae63e8415a028a3811efe665d
4
- data.tar.gz: 33fd5a5c73b159830d8e545be1ea9b5fde0b0250
3
+ metadata.gz: c3e6b1c29dbf1ebfb965fb46cc8b4d6a74b99c0c
4
+ data.tar.gz: 82a5ec063e3d282c9c87ae670ca09ed009d0a3de
5
5
  SHA512:
6
- metadata.gz: a236ee7822df8302c33e32b2a2d14ee0a359bf0ea0bccfc9e46645583cad6e8f0889c3761b63351ff770bf461d4e6308cc9ca945765e2eea4a1acc72e372dfaa
7
- data.tar.gz: f347074030ae403b3093dd73c4931a41aefee52c4d18b38576c5105fa4bbf5fd606f2579f273cfed68b2c712186149dd4eb20049c9957c6ebfc68ec322ed7860
6
+ metadata.gz: ce52fb6b99913e16cbf5d44f2f076e24d3fc36bfe95427f345faca78ba1895f14d9c46d26e4d74ee396c47250161220244be9d3f5e573b5fffdf9e1274d0ae08
7
+ data.tar.gz: 4a231f9e05a15535a95d713f10aa3c822989358666679d15756e5e1d30abc2391c77c5d814406b8430dbad581691baf3e10291a539d33005397f5df30b8e6770
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.4.0
3
4
  - 2.3.0
4
- - 1.9.3
5
- - jruby-19mode
6
5
  before_install:
7
6
  - gem install bundler
8
7
  before_script:
data/README.md CHANGED
@@ -51,6 +51,7 @@ Print all messages as they occur:
51
51
  ```ruby
52
52
  j = Systemd::Journal.new
53
53
  j.seek(:tail)
54
+ j.move_previous
54
55
 
55
56
  # watch() does not return
56
57
  j.watch do |entry|
@@ -81,9 +82,9 @@ c = j.cursor # get a reference to this entry
81
82
  j.move(-5) # move back 5 entries
82
83
  j.seek(c) # move to the saved cursor
83
84
  j.cursor?(c) # verify that we're at the correct entry
84
- j.seek(:tail) # move to end of the journal
85
- j.move_previous # move back
86
- j.move_next # move forward
85
+ j.seek(:tail) # move past the end of the journal
86
+ j.move_previous # move to last entry in journal
87
+ j.move_next # move forward (fails since we're at the end)
87
88
 
88
89
  j.current_entry # get the entry we're currently positioned at
89
90
 
@@ -96,6 +97,7 @@ Waiting for things to happen:
96
97
  ```ruby
97
98
  j = Systemd::Journal.new
98
99
  j.seek(:tail)
100
+ j.move_previous
99
101
  # wait up to one second for something to happen
100
102
  if j.wait(1_000_000)
101
103
  puts 'something changed!'
@@ -145,7 +147,8 @@ a valid entry:
145
147
  Journal#seek(:tail)
146
148
 
147
149
  The solution is to always call one of `move`, `move_next`, `move_previous` and
148
- friends before reading after issuing one of the above calls.
150
+ friends before reading after issuing one of the above calls. For most functions,
151
+ call `move_next`. For `seek(:tail)`, call `move_previous`.
149
152
 
150
153
  ## Issues?
151
154
 
@@ -1,21 +1,21 @@
1
1
  -----BEGIN CERTIFICATE-----
2
2
  MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARqb2hu
3
3
  MRgwFgYKCZImiZPyLGQBGRYIdGhyb3R0bGUxEjAQBgoJkiaJk/IsZAEZFgJpbzAe
4
- Fw0xNjAxMTcxNjEyNDlaFw0xNzAxMTYxNjEyNDlaMD0xDTALBgNVBAMMBGpvaG4x
4
+ Fw0xNzA4MDgxNDMyMjdaFw0xODA4MDgxNDMyMjdaMD0xDTALBgNVBAMMBGpvaG4x
5
5
  GDAWBgoJkiaJk/IsZAEZFgh0aHJvdHRsZTESMBAGCgmSJomT8ixkARkWAmlvMIIB
6
- IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsKoOAl3GjhyD0ijDTrgKRdN2
7
- LgFc59HUFYKLfPnCxH3LLxyFEQWMyxmqwetUAQ2SALKNM2U+rr4Dvv39sqEjvYHn
8
- prWK8+XuvvBYHeH2E5K0uQjwZ5yIo8wsqc0ae46cBZoRjvlWFo3ha6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YeYZU0tPBJHHKxW19wmdis59/ktMo5JOGCBRKYNwcOYEaMUP3Mrmc+ZDk3
11
+ YikJg7xL8eQa3qJjZ5xEeXSI34u2VUqBmqs2CMH4ZvdXZl4rZrFZs8uePdxCxQID
12
+ AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU3jyZnlOE
13
+ slGWjYuqMAfdqBCyoaUwGwYDVR0RBBQwEoEQam9obkB0aHJvdHRsZS5pbzAbBgNV
14
+ HRIEFDASgRBqb2huQHRocm90dGxlLmlvMA0GCSqGSIb3DQEBBQUAA4IBAQCdXeiJ
15
+ 7LDI9AdMXqJsDAHps+2sN/77BLxuNXB3BZRgrJ0+VaSfNKdMvf69h195bFjP/VD5
16
+ PePsf+ZoQTOVpPaunWP2u4Np9NgXi3EWywLAlmEqt1/1P2Cw4QOePTV/BVs4XRal
17
+ hnjXkfWlHd6ngozGr4ICBR0x0WqLRR09pSKuwEUspzUWuunU5Z0vJPHDZAoTGdrR
18
+ fqWHVr6WwoNUEZH3D+kMyJNwDpuq5m0n/iKhHypAE1LI0l4EapKzSXlBImywCTIh
19
+ LnHNrDPklxqI1pnkXyKU9OrcCVuFnKY6te48kWZ8ZN/WhegL1fbNtLuvgoS2WuUJ
20
+ 5MDu0m5ogQUz8Ijw
21
21
  -----END CERTIFICATE-----
@@ -10,6 +10,7 @@ class SSHWatcher
10
10
  def run
11
11
  @journal.filter(_exe: '/usr/bin/sshd')
12
12
  @journal.seek(:tail)
13
+ @journal.move_previous
13
14
  @journal.watch{ |entry| process_event(entry) }
14
15
  end
15
16
 
@@ -1,4 +1,4 @@
1
- require 'systemd/journal'
1
+ require 'systemd/id128'
2
2
 
3
3
  module Systemd
4
4
  # See {Systemd::Id128.machine_id}.
@@ -191,6 +191,22 @@ module Systemd
191
191
  end
192
192
  end
193
193
 
194
+ # Explicitly close the underlying Journal file.
195
+ # Once this is done, any operations on the instance will fail and raise an
196
+ # exception.
197
+ def close
198
+ return if @ptr.nil?
199
+
200
+ ObjectSpace.undefine_finalizer(self)
201
+ Native.sd_journal_close(@ptr)
202
+
203
+ @ptr = nil
204
+ end
205
+
206
+ def closed?
207
+ @ptr.nil?
208
+ end
209
+
194
210
  # @private
195
211
  def inspect
196
212
  format(
@@ -78,6 +78,9 @@ module Systemd
78
78
  # Seek to a position in the journal.
79
79
  # Note: after seeking, you must call {#move_next} or {#move_previous}
80
80
  # before you can call {#read_field} or {#current_entry}.
81
+ # When calling `seek(:tail)` the read pointer is positioned _after_
82
+ # the last entry in the journal -- thus you should use `move_previous`.
83
+ # Otherwise, use `move_next`.
81
84
  #
82
85
  # @param [Symbol, Time] whence one of :head, :tail, or a Time instance.
83
86
  # `:head` (or `:start`) will seek to the beginning of the journal.
@@ -86,6 +89,11 @@ module Systemd
86
89
  # time. When a String is provided, assume it is a cursor from {#cursor}
87
90
  # and seek to that entry.
88
91
  # @return [True]
92
+ # @example Read last journal entry
93
+ # j = Systemd::Joural.new
94
+ # j.seek(:tail)
95
+ # j.move_previous
96
+ # puts j.current_entry
89
97
  def seek(where)
90
98
  rc = case
91
99
  when [:head, :start].include?(where)
@@ -1,6 +1,6 @@
1
1
  module Systemd
2
2
  class Journal
3
3
  # The version of the systemd-journal gem.
4
- VERSION = '1.2.3'
4
+ VERSION = '1.3.0'
5
5
  end
6
6
  end
@@ -20,7 +20,7 @@ module Systemd
20
20
  wait_select(timeout_usec)
21
21
  else
22
22
  rc = Native.sd_journal_wait(@ptr, timeout_usec)
23
- raise JournalError, rc if rc.is_a?(Fixnum) && rc < 0
23
+ raise JournalError, rc if rc.is_a?(Integer) && rc < 0
24
24
  rc == :nop ? nil : rc
25
25
  end
26
26
  end
@@ -67,7 +67,7 @@ module Systemd
67
67
 
68
68
  def reason_for_wakeup
69
69
  rc = Native.sd_journal_process(@ptr)
70
- raise JournalError, rc if rc.is_a?(Fixnum) && rc < 0
70
+ raise JournalError, rc if rc.is_a?(Integer) && rc < 0
71
71
  rc == :nop ? nil : rc
72
72
  end
73
73
  end
@@ -25,6 +25,34 @@ RSpec.describe Systemd::Journal do
25
25
  end
26
26
  end
27
27
 
28
+ describe 'close' do
29
+ it 'closes the underlying file' do
30
+ expect(Systemd::Journal::Native).to receive(:sd_journal_close)
31
+ .and_call_original
32
+
33
+ j.close
34
+ end
35
+
36
+ it 'unregisters the finalizer' do
37
+ expect(ObjectSpace).to receive(:undefine_finalizer)
38
+ .with(j)
39
+ .and_call_original
40
+
41
+ j.close
42
+ end
43
+
44
+ it 'does not fail if called more than once' do
45
+ j.close
46
+ expect { j.close }.to_not raise_error
47
+ end
48
+
49
+ it 'marks the journal as closed' do
50
+ expect(j).to_not be_closed
51
+ j.close
52
+ expect(j).to be_closed
53
+ end
54
+ end
55
+
28
56
  describe 'query_unique' do
29
57
  it 'throws a JournalError on invalid return code' do
30
58
  expect(Systemd::Journal::Native).to receive(:sd_journal_enumerate_unique)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: systemd-journal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Ledbetter
@@ -13,25 +13,25 @@ cert_chain:
13
13
  -----BEGIN CERTIFICATE-----
14
14
  MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARqb2hu
15
15
  MRgwFgYKCZImiZPyLGQBGRYIdGhyb3R0bGUxEjAQBgoJkiaJk/IsZAEZFgJpbzAe
16
- Fw0xNjAxMTcxNjEyNDlaFw0xNzAxMTYxNjEyNDlaMD0xDTALBgNVBAMMBGpvaG4x
16
+ Fw0xNzA4MDgxNDMyMjdaFw0xODA4MDgxNDMyMjdaMD0xDTALBgNVBAMMBGpvaG4x
17
17
  GDAWBgoJkiaJk/IsZAEZFgh0aHJvdHRsZTESMBAGCgmSJomT8ixkARkWAmlvMIIB
18
- IjANBgkqhkiG9w0BAQEFAAOCA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xbBKddwVvwkT+u/pBMce6B
20
+ cATETUMYjzryb+5Sbf1k0MFiIsAc9ASlP5OWF3cQTefJhpGlklqCZwpdBeh5p4XM
21
+ WYJ85StSH/OzMg0PcX07d1Ps5MmLV7qyMQEvaOCKnme5OmxCQzVBv3ySgyBLh7hj
22
+ gUUzMFYeYZU0tPBJHHKxW19wmdis59/ktMo5JOGCBRKYNwcOYEaMUP3Mrmc+ZDk3
23
+ YikJg7xL8eQa3qJjZ5xEeXSI34u2VUqBmqs2CMH4ZvdXZl4rZrFZs8uePdxCxQID
24
+ AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU3jyZnlOE
25
+ slGWjYuqMAfdqBCyoaUwGwYDVR0RBBQwEoEQam9obkB0aHJvdHRsZS5pbzAbBgNV
26
+ HRIEFDASgRBqb2huQHRocm90dGxlLmlvMA0GCSqGSIb3DQEBBQUAA4IBAQCdXeiJ
27
+ 7LDI9AdMXqJsDAHps+2sN/77BLxuNXB3BZRgrJ0+VaSfNKdMvf69h195bFjP/VD5
28
+ PePsf+ZoQTOVpPaunWP2u4Np9NgXi3EWywLAlmEqt1/1P2Cw4QOePTV/BVs4XRal
29
+ hnjXkfWlHd6ngozGr4ICBR0x0WqLRR09pSKuwEUspzUWuunU5Z0vJPHDZAoTGdrR
30
+ fqWHVr6WwoNUEZH3D+kMyJNwDpuq5m0n/iKhHypAE1LI0l4EapKzSXlBImywCTIh
31
+ LnHNrDPklxqI1pnkXyKU9OrcCVuFnKY6te48kWZ8ZN/WhegL1fbNtLuvgoS2WuUJ
32
+ 5MDu0m5ogQUz8Ijw
33
33
  -----END CERTIFICATE-----
34
- date: 2016-09-17 00:00:00.000000000 Z
34
+ date: 2017-08-08 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffi
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.5.1
195
+ rubygems_version: 2.6.11
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Ruby bindings to libsystemd-journal
@@ -204,4 +204,3 @@ test_files:
204
204
  - spec/systemd/journal_entry_spec.rb
205
205
  - spec/systemd/journal_spec.rb
206
206
  - spec/systemd_spec.rb
207
- has_rdoc:
metadata.gz.sig CHANGED
Binary file