systemd-journal 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +1 -2
- data/README.md +7 -4
- data/certs/john@throttle.io.pem +16 -16
- data/examples/ssh_watcher.rb +1 -0
- data/lib/systemd.rb +1 -1
- data/lib/systemd/journal.rb +16 -0
- data/lib/systemd/journal/navigable.rb +8 -0
- data/lib/systemd/journal/version.rb +1 -1
- data/lib/systemd/journal/waitable.rb +2 -2
- data/spec/systemd/journal_spec.rb +28 -0
- metadata +19 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3e6b1c29dbf1ebfb965fb46cc8b4d6a74b99c0c
|
4
|
+
data.tar.gz: 82a5ec063e3d282c9c87ae670ca09ed009d0a3de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce52fb6b99913e16cbf5d44f2f076e24d3fc36bfe95427f345faca78ba1895f14d9c46d26e4d74ee396c47250161220244be9d3f5e573b5fffdf9e1274d0ae08
|
7
|
+
data.tar.gz: 4a231f9e05a15535a95d713f10aa3c822989358666679d15756e5e1d30abc2391c77c5d814406b8430dbad581691baf3e10291a539d33005397f5df30b8e6770
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
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
|
85
|
-
j.move_previous # move
|
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
|
|
data/certs/john@throttle.io.pem
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARqb2hu
|
3
3
|
MRgwFgYKCZImiZPyLGQBGRYIdGhyb3R0bGUxEjAQBgoJkiaJk/IsZAEZFgJpbzAe
|
4
|
-
|
4
|
+
Fw0xNzA4MDgxNDMyMjdaFw0xODA4MDgxNDMyMjdaMD0xDTALBgNVBAMMBGpvaG4x
|
5
5
|
GDAWBgoJkiaJk/IsZAEZFgh0aHJvdHRsZTESMBAGCgmSJomT8ixkARkWAmlvMIIB
|
6
|
-
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TIh
|
19
|
+
LnHNrDPklxqI1pnkXyKU9OrcCVuFnKY6te48kWZ8ZN/WhegL1fbNtLuvgoS2WuUJ
|
20
|
+
5MDu0m5ogQUz8Ijw
|
21
21
|
-----END CERTIFICATE-----
|
data/examples/ssh_watcher.rb
CHANGED
data/lib/systemd.rb
CHANGED
data/lib/systemd/journal.rb
CHANGED
@@ -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)
|
@@ -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?(
|
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?(
|
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.
|
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
|
-
|
16
|
+
Fw0xNzA4MDgxNDMyMjdaFw0xODA4MDgxNDMyMjdaMD0xDTALBgNVBAMMBGpvaG4x
|
17
17
|
GDAWBgoJkiaJk/IsZAEZFgh0aHJvdHRsZTESMBAGCgmSJomT8ixkARkWAmlvMIIB
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
18
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoNysk6eAiijtXvE+Yp+i5n/g
|
19
|
+
n6mzDAuV5cA2E37v5LUCnNJXRnVOt0pO+CfWw0AV8dxbBKddwVvwkT+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:
|
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.
|
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
|