systemd-journal 2.1.1 → 2.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f33c8fad86b5eee9fa452aefe9b33984383cea940b21075c6394c1a1d4ce85ef
4
- data.tar.gz: fb07b5691db94be4abb21e7b2ca9a9541be0863e11e3899dcd55c16e52661a43
3
+ metadata.gz: 189453bd430728113357d90bca13700af3f2f9f0e5ca48645a95ba8ee07b7efc
4
+ data.tar.gz: 2956619d81630a3812c4a487b8defe08611f63e1d2a7fedea33aaa525a686ed1
5
5
  SHA512:
6
- metadata.gz: 2345a7cb623c6998f2f2aee2136e55b6c79278fd9fe5b223f548cbcf3f0b176cbe58e019f19a9a0ee547015a3f0f3b969509eb488f1feb86464412f357f821ea
7
- data.tar.gz: '09323d66962413d09ebb444d0667d1d3d35cb4208ea388910233bb2a28368de63b97f2cd1a8d046bc205c872cb2f348f4a8fa4bcc41b715012cc7c149937af4a'
6
+ metadata.gz: c04fb459d751bde66821602d51613dbcf6e52055bc5d9a1411da5f71177a096a0eabddf7b75465c23df637b52147d3033905d71bb53d58705fff2f27cd04322d
7
+ data.tar.gz: 26681192b834375a1089b2c1d4bcc33ea9f036b46e7719f1eda4ddff8df0f0f968f7e1d9b0cb5683d737ce2a69aa2dc82c1dadc11a291fc7b862d04cc16f5ece
data/lib/systemd/id128.rb CHANGED
@@ -43,6 +43,7 @@ module Systemd
43
43
  module Native
44
44
  require "ffi"
45
45
  extend FFI::Library
46
+
46
47
  ffi_lib %w[ libsystemd.so.0 libsystemd.so
47
48
  libsystemd-id128.so.0 libsystemd-id128.so ]
48
49
 
@@ -8,6 +8,7 @@ module Systemd
8
8
  # rubocop:disable Layout/LineLength
9
9
  require "ffi"
10
10
  extend FFI::Library
11
+
11
12
  ffi_lib %w[ libsystemd.so.0 libsystemd.so
12
13
  libsystemd-journal.so.0 libsystemd-journal.so]
13
14
 
@@ -78,7 +79,7 @@ module Systemd
78
79
 
79
80
  # writing
80
81
  attach_function :sd_journal_print, [:int, :string], :int
81
- attach_function :sd_journal_send, [:varargs], :int
82
+ attach_function :sd_journal_send, [:string, :varargs], :int
82
83
  attach_function :sd_journal_perror, [:string], :int
83
84
  attach_function :sd_journal_stream_fd, [:string, :int, :bool], :int
84
85
 
@@ -1,6 +1,6 @@
1
1
  module Systemd
2
2
  class Journal
3
3
  # The version of the systemd-journal gem.
4
- VERSION = "2.1.1".freeze
4
+ VERSION = "2.1.2".freeze
5
5
  end
6
6
  end
@@ -78,8 +78,7 @@ module Systemd
78
78
  [:string, "#{k.to_s.upcase}=#{value}"]
79
79
  end
80
80
  # add a null pointer to terminate the varargs
81
- items += [:string, nil]
82
- rc = Native.sd_journal_send(*items)
81
+ rc = Native.sd_journal_send(*items[1..], :pointer, nil)
83
82
  raise JournalError, rc if rc < 0
84
83
  end
85
84
  end
@@ -263,7 +263,7 @@ module Systemd
263
263
  Native.sd_journal_open_directory(ptr, opts[:path], 0)
264
264
  when :files, :file
265
265
  files = Array(opts[type])
266
- @open_target = "file#{files.one? ? "" : "s"}:#{files.join(",")}"
266
+ @open_target = "file#{"s" unless files.one?}:#{files.join(",")}"
267
267
  Native.sd_journal_open_files(ptr, array_to_ptrs(files), 0)
268
268
  when :container
269
269
  @open_target = "container:#{opts[:container]}"
@@ -18,6 +18,7 @@ module Systemd
18
18
  # @private
19
19
  module LIBC
20
20
  extend FFI::Library
21
+
21
22
  ffi_lib FFI::Library::LIBC
22
23
 
23
24
  attach_function :strerror, [:int], :string
@@ -480,10 +480,32 @@ RSpec.describe Systemd::Journal do
480
480
  describe "message" do
481
481
  it "escapes percent signs in messages" do
482
482
  expect(Systemd::Journal::Native).to receive(:sd_journal_send)
483
- .with(:string, "MESSAGE=hello %% world %%", :string, nil)
483
+ .with("MESSAGE=hello %% world %%", :string, "CUSTOM_FIELD=test", :pointer, nil)
484
484
  .and_return(0)
485
485
 
486
- Systemd::Journal.message(message: "hello % world %")
486
+ Systemd::Journal.message(message: "hello % world %", custom_field: "test")
487
+ end
488
+
489
+ it "sends message to journal" do
490
+ Systemd::Journal.message(message: "test message")
491
+ end
492
+
493
+ it "sends message with priority and custom field to journal" do
494
+ Systemd::Journal.message(
495
+ message: "test message",
496
+ priority: Systemd::Journal::LOG_ERR,
497
+ custom_field: "hello world"
498
+ )
499
+
500
+ j = Systemd::Journal.new
501
+ j.seek(:tail)
502
+ j.move_previous
503
+
504
+ expect(j.current_entry).to have_attributes(
505
+ message: "test message",
506
+ custom_field: "hello world",
507
+ priority: Systemd::Journal::LOG_ERR.to_s
508
+ )
487
509
  end
488
510
  end
489
511
 
@@ -495,5 +517,18 @@ RSpec.describe Systemd::Journal do
495
517
 
496
518
  Systemd::Journal.print(Systemd::Journal::LOG_DEBUG, "hello % world %")
497
519
  end
520
+
521
+ it "prints to journal" do
522
+ Systemd::Journal.print(Systemd::Journal::LOG_DEBUG, "hello % world !")
523
+
524
+ j = Systemd::Journal.new
525
+ j.seek(:tail)
526
+ j.move_previous
527
+
528
+ expect(j.current_entry).to have_attributes(
529
+ message: "hello % world !",
530
+ priority: Systemd::Journal::LOG_DEBUG.to_s
531
+ )
532
+ end
498
533
  end
499
534
  end
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: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Ledbetter
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubygems_version: 3.6.7
188
+ rubygems_version: 3.7.2
189
189
  specification_version: 4
190
190
  summary: Ruby bindings to libsystemd-journal
191
191
  test_files: []