systemd-journal 1.3.3 → 1.4.1

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
- SHA256:
3
- metadata.gz: a2558fb9916c7c32730f0a9e5d546b554527f65fd6f594c58f5abfb25a15ae20
4
- data.tar.gz: 28d2597709dbb8008d893035b5f01ae9c270d6cc291f453a87a08436b42b03c5
2
+ SHA1:
3
+ metadata.gz: 7954a07279ccaf744edb91b9d0ddf2dacd24cb66
4
+ data.tar.gz: c8ef65bcdd2d50edc7a48c45370120b34eb2025b
5
5
  SHA512:
6
- metadata.gz: 1759e62cc2b655b54e51d74f09744bf56e79f7d001601440db008bbf26de4055783429858332128398e1198151b9f9fb19dfaa0c5c7b3f4d152637a66af45a0d
7
- data.tar.gz: 200d4f6034ad779f2d64437d3cf06b2a7e91fb196461bf89a7d61cec8d380351acc3b10149a8540ee9c782e7f601216ffbe0cce034431bb6252bd980714f0406
6
+ metadata.gz: 39ad407354a6850dca2ce66b4e6a5073468fbd7d4124e99dcc4e1777629783c50a190855714aeed313920ffdd84dc65fc164a11a869e2fe56009809671b467bc
7
+ data.tar.gz: f1b2f96ba311b770772e88f8692f35746d0f7d615e723bd2f484237696abd2946162e40ef07841bae731492780b645161cb4e6d9042454984d185ff5b8528abe
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -49,13 +49,14 @@ require 'systemd/journal'
49
49
  Print all messages as they occur:
50
50
 
51
51
  ```ruby
52
- j = Systemd::Journal.new
53
- j.seek(:tail)
54
- j.move_previous
55
-
56
- # watch() does not return
57
- j.watch do |entry|
58
- puts entry.message
52
+ Systemd::Journal.open do |j|
53
+ j.seek(:tail)
54
+ j.move_previous
55
+
56
+ # watch() does not return
57
+ j.watch do |entry|
58
+ puts entry.message
59
+ end
59
60
  end
60
61
  ```
61
62
 
@@ -69,6 +70,7 @@ j.filter(priority: 6, _exe: '/usr/bin/sshd')
69
70
  j.each do |entry|
70
71
  puts entry.message
71
72
  end
73
+ j.close # close open files
72
74
  ```
73
75
 
74
76
  Moving around the journal:
@@ -99,11 +101,10 @@ j = Systemd::Journal.new
99
101
  j.seek(:tail)
100
102
  j.move_previous
101
103
  # wait up to one second for something to happen
102
- if j.wait(1_000_000)
103
- puts 'something changed!'
104
+ puts 'something changed!' if j.wait(1_000_000)
105
+
104
106
  # same as above, but can be interrupted with Control+C.
105
- if j.wait(1_000_000, select: true)
106
- puts 'something changed!'
107
+ puts 'something changed!' if j.wait(1_000_000, select: true)
107
108
  ```
108
109
 
109
110
  Accessing the catalog:
@@ -1,21 +1,21 @@
1
1
  -----BEGIN CERTIFICATE-----
2
2
  MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARqb2hu
3
3
  MRgwFgYKCZImiZPyLGQBGRYIdGhyb3R0bGUxEjAQBgoJkiaJk/IsZAEZFgJpbzAe
4
- Fw0xNzA4MDgxNDMyMjdaFw0xODA4MDgxNDMyMjdaMD0xDTALBgNVBAMMBGpvaG4x
4
+ Fw0xOTAzMDUyMDM1MjZaFw0yMDAzMDQyMDM1MjZaMD0xDTALBgNVBAMMBGpvaG4x
5
5
  GDAWBgoJkiaJk/IsZAEZFgh0aHJvdHRsZTESMBAGCgmSJomT8ixkARkWAmlvMIIB
6
- IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoNysk6eAiijtXvE+Yp+i5n/g
7
- n6mzDAuV5cA2E37v5LUCnNJXRnVOt0pO+CfWw0AV8dxbBKddwVvwkT+u/pBMce6B
8
- cATETUMYjzryb+5Sbf1k0MFiIsAc9ASlP5OWF3cQTefJhpGlklqCZwpdBeh5p4XM
9
- WYJ85StSH/OzMg0PcX07d1Ps5MmLV7qyMQEvaOCKnme5OmxCQzVBv3ySgyBLh7hj
10
- gUUzMFYeYZU0tPBJHHKxW19wmdis59/ktMo5JOGCBRKYNwcOYEaMUP3Mrmc+ZDk3
11
- YikJg7xL8eQa3qJjZ5xEeXSI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wIEsDAdBgNVHQ4EFgQUnFpnqd56
13
+ KP6ORCFp9LEvackdywQwGwYDVR0RBBQwEoEQam9obkB0aHJvdHRsZS5pbzAbBgNV
14
+ HRIEFDASgRBqb2huQHRocm90dGxlLmlvMA0GCSqGSIb3DQEBBQUAA4IBAQCNvyn1
15
+ 8hDTha8YvQtrJd5OTNoMztU3k+1zsv4KzAkvqcp1TpJfTF54GLq4QXcUYaepxCTW
16
+ PUBdWX8cgjZePmJ005KT3MPtA//o1nATLyYWc86Xk02FI9f7h4K6lSHMUr/L2fVL
17
+ 9DahKJje3A0xvOupPKojNqHRB8NPwOV7lbD9Na8vqymCxqahh6VYGreAHAmoFJLw
18
+ Hw1jejkkg22p795C8ajT+BVGkALv64eUKBcg43XRiEdURHk6N0a9hPeV+F0pXJSi
19
+ qFmZlFSs2UEGpMrcVelMgdQ5dBFzZ/SIvfYO70bQhRRae39Z/QmV0jEgYx5f2Q1d
20
+ bc0+je0pm4TYY6oC
21
21
  -----END CERTIFICATE-----
@@ -48,12 +48,20 @@ module Systemd
48
48
  open_type, flags = validate_options!(opts)
49
49
  ptr = FFI::MemoryPointer.new(:pointer, 1)
50
50
 
51
+ @finalize = (opts.key?(:finalize) ? opts.delete(:finalize) : true)
51
52
  rc = open_journal(open_type, ptr, opts, flags)
52
53
  raise JournalError, rc if rc < 0
53
54
 
54
55
  @ptr = ptr.read_pointer
55
56
  file_descriptor
56
- ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))
57
+ ObjectSpace.define_finalizer(self, self.class.finalize(@ptr)) if @finalize
58
+ end
59
+
60
+ def self.open(opts = {})
61
+ j = new(opts.merge(finalize: false))
62
+ yield j
63
+ ensure
64
+ j.close if j
57
65
  end
58
66
 
59
67
  # Iterate over each entry in the journal, respecting the applied
@@ -198,7 +206,7 @@ module Systemd
198
206
  def close
199
207
  return if @ptr.nil?
200
208
 
201
- ObjectSpace.undefine_finalizer(self)
209
+ ObjectSpace.undefine_finalizer(self) if @finalize
202
210
  Native.sd_journal_close(@ptr)
203
211
 
204
212
  @ptr = nil
@@ -1,6 +1,6 @@
1
1
  module Systemd
2
2
  class Journal
3
3
  # The version of the systemd-journal gem.
4
- VERSION = '1.3.3'
4
+ VERSION = '1.4.1'
5
5
  end
6
6
  end
@@ -8,6 +8,24 @@ RSpec.describe Systemd::Journal do
8
8
  end
9
9
  end
10
10
 
11
+ describe 'open' do
12
+ it 'creates and closes' do
13
+ expect(Systemd::Journal::Native).to receive(:sd_journal_close)
14
+ .and_call_original
15
+
16
+ result = j.open { 1 }
17
+ expect(result).to eq 1
18
+ end
19
+
20
+ it 'raises original exception when creating journal fails' do
21
+ expect(Systemd::Journal::Native).to_not receive(:sd_journal_close)
22
+
23
+ expect do
24
+ j.open(file: 1, path: 2, files: 3) { 1 }
25
+ end.to raise_error(ArgumentError)
26
+ end
27
+ end
28
+
11
29
  describe 'initialize' do
12
30
  subject(:j) { Systemd::Journal }
13
31
 
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.3.3
4
+ version: 1.4.1
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
- Fw0xNzA4MDgxNDMyMjdaFw0xODA4MDgxNDMyMjdaMD0xDTALBgNVBAMMBGpvaG4x
16
+ Fw0xOTAzMDUyMDM1MjZaFw0yMDAzMDQyMDM1MjZaMD0xDTALBgNVBAMMBGpvaG4x
17
17
  GDAWBgoJkiaJk/IsZAEZFgh0aHJvdHRsZTESMBAGCgmSJomT8ixkARkWAmlvMIIB
18
- IjANBgkqhkiG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JyofRQxfzY0lGWC8Xtd+bRt04WVznerSNqbPFP
20
+ Gou2NHQvI77T/UDvjYvbf+7ZVYHgWHzIjoFAHeUDV0hAMPIizoX04nDsPSqiKHxp
21
+ 6fypG8eLdiMn+Ab8/M+94FeXL/EhSQcvOFE0P98SgYu57jhPfbdH4IeN+eIoO8e7
22
+ yjbi6jbtVa2k9ZDi4mlg0f8cH8nYXfO9wKDW3lcPa4Le4MwIAy70iEozoxdDQd+X
23
+ 5X2ZYk2Mcss+FxhzZro/ChJgdGWk0gM632koFaIuCRgmtp2a915WXhMrsYyrsQID
24
+ AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUnFpnqd56
25
+ KP6ORCFp9LEvackdywQwGwYDVR0RBBQwEoEQam9obkB0aHJvdHRsZS5pbzAbBgNV
26
+ HRIEFDASgRBqb2huQHRocm90dGxlLmlvMA0GCSqGSIb3DQEBBQUAA4IBAQCNvyn1
27
+ 8hDTha8YvQtrJd5OTNoMztU3k+1zsv4KzAkvqcp1TpJfTF54GLq4QXcUYaepxCTW
28
+ PUBdWX8cgjZePmJ005KT3MPtA//o1nATLyYWc86Xk02FI9f7h4K6lSHMUr/L2fVL
29
+ 9DahKJje3A0xvOupPKojNqHRB8NPwOV7lbD9Na8vqymCxqahh6VYGreAHAmoFJLw
30
+ Hw1jejkkg22p795C8ajT+BVGkALv64eUKBcg43XRiEdURHk6N0a9hPeV+F0pXJSi
31
+ qFmZlFSs2UEGpMrcVelMgdQ5dBFzZ/SIvfYO70bQhRRae39Z/QmV0jEgYx5f2Q1d
32
+ bc0+je0pm4TYY6oC
33
33
  -----END CERTIFICATE-----
34
- date: 2018-07-31 00:00:00.000000000 Z
34
+ date: 2019-03-25 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffi
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.7.7
198
+ rubygems_version: 2.6.14.1
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Ruby bindings to libsystemd-journal
metadata.gz.sig CHANGED
Binary file