remote_syslog_sender 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: 9badc24ba1d4b6b484a7e5395c0ae68eb162e6c1
4
- data.tar.gz: 68952f70023a41578e0778aebfcc687b6ac38e3d
3
+ metadata.gz: 860ccfa2eb6457c816ad1461a9c6f2e1ab26827f
4
+ data.tar.gz: c0e4d13e4d178258ebc63e5096e845ad4f8447f9
5
5
  SHA512:
6
- metadata.gz: 0704cd78a41574090d1cd3a8304c8f8321acefa6eedd2874f8639926eae8459dd94bebb2d3e16305b9547faf8a667c685ad8f156345eecf24e7aa585a64e0e13
7
- data.tar.gz: fe35a63e7c0979457eb57955afdb1248f656146f87a728776999e3eacddd2d828aaefe00b5ffb4420725015b0c635a83fde82144cb003e03dfee5ffd2231ca6b
6
+ metadata.gz: 6bba3380a97df8bdeb452580f2a16192c50d7a94598c2968ab3174781068e26aa5a82f5cdeb2218f15648c31cb4c8c8046a78ed8ee4ef9b0aedb89b1bbce3611
7
+ data.tar.gz: 4d265b126e5f4173c18ff685b57b52362ae69a519c89b7d47363595a4b73db064839344586071eb2a357810efb013c329272bb9cff5cf7f9497d159d560e6076
@@ -11,6 +11,9 @@ module RemoteSyslogSender
11
11
  end
12
12
  end
13
13
 
14
+ attr_reader :socket
15
+ attr_accessor :packet
16
+
14
17
  def initialize(remote_hostname, remote_port, options = {})
15
18
  @remote_hostname = remote_hostname
16
19
  @remote_port = remote_port
@@ -19,22 +22,29 @@ module RemoteSyslogSender
19
22
 
20
23
  @packet = Packet.new
21
24
 
22
- local_hostname = options[:local_hostname] || (Socket.gethostname rescue `hostname`.chomp)
25
+ local_hostname = options[:hostname] || options[:local_hostname] || (Socket.gethostname rescue `hostname`.chomp)
23
26
  local_hostname = 'localhost' if local_hostname.nil? || local_hostname.empty?
24
27
  @packet.hostname = local_hostname
25
28
 
26
29
  @packet.facility = options[:facility] || 'user'
27
30
  @packet.severity = options[:severity] || 'notice'
28
- @packet.tag = options[:program] || "#{File.basename($0)}[#{$$}]"
31
+ @packet.tag = options[:tag] || options[:program] || "#{File.basename($0)}[#{$$}]"
29
32
 
30
33
  @socket = nil
31
34
  end
32
35
 
33
- def transmit(message)
36
+ def transmit(message, packet_options = nil)
34
37
  message.split(/\r?\n/).each do |line|
35
38
  begin
36
39
  next if line =~ /^\s*$/
37
40
  packet = @packet.dup
41
+ if packet_options
42
+ packet.tag = packet_options[:program] if packet_options[:program]
43
+ packet.hostname = packet_options[:local_hostname] if packet_options[:local_hostname]
44
+ %i(hostname facility severity tag).each do |key|
45
+ packet.send("#{key}=", packet_options[key]) if packet_options[key]
46
+ end
47
+ end
38
48
  packet.content = line
39
49
  send_msg(packet.assemble(@packet_size))
40
50
  rescue
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'remote_syslog_sender'
3
- s.version = '1.1.0'
3
+ s.version = '1.1.1'
4
4
  s.summary = "Message sender that sends directly to a remote syslog endpoint"
5
5
  s.description = "Message sender that sends directly to a remote syslog endpoint (Support UDP, TCP, TCP+TLS)"
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_syslog_sender
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomohiro Hashidate