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 +4 -4
- data/lib/systemd/id128.rb +1 -0
- data/lib/systemd/journal/native.rb +2 -1
- data/lib/systemd/journal/version.rb +1 -1
- data/lib/systemd/journal/writable.rb +1 -2
- data/lib/systemd/journal.rb +1 -1
- data/lib/systemd/journal_error.rb +1 -0
- data/spec/systemd/journal_spec.rb +37 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 189453bd430728113357d90bca13700af3f2f9f0e5ca48645a95ba8ee07b7efc
|
|
4
|
+
data.tar.gz: 2956619d81630a3812c4a487b8defe08611f63e1d2a7fedea33aaa525a686ed1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c04fb459d751bde66821602d51613dbcf6e52055bc5d9a1411da5f71177a096a0eabddf7b75465c23df637b52147d3033905d71bb53d58705fff2f27cd04322d
|
|
7
|
+
data.tar.gz: 26681192b834375a1089b2c1d4bcc33ea9f036b46e7719f1eda4ddff8df0f0f968f7e1d9b0cb5683d737ce2a69aa2dc82c1dadc11a291fc7b862d04cc16f5ece
|
data/lib/systemd/id128.rb
CHANGED
|
@@ -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
|
|
|
@@ -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
|
-
|
|
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
|
data/lib/systemd/journal.rb
CHANGED
|
@@ -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?
|
|
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]}"
|
|
@@ -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(
|
|
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.
|
|
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.
|
|
188
|
+
rubygems_version: 3.7.2
|
|
189
189
|
specification_version: 4
|
|
190
190
|
summary: Ruby bindings to libsystemd-journal
|
|
191
191
|
test_files: []
|