remote_syslog_logger 1.0.3 → 1.0.4
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 +7 -0
- data/README.md +80 -5
- data/Rakefile +2 -2
- data/lib/remote_syslog_logger.rb +2 -2
- data/lib/remote_syslog_logger/udp_sender.rb +3 -1
- data/remote_syslog_logger.gemspec +2 -2
- data/test/helper.rb +1 -1
- data/test/test_remote_syslog_logger.rb +7 -7
- metadata +33 -53
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d41ee52d805583b5c45dc0b96f2d8a7c85ff192eefe52b640d926ef21694a899
|
4
|
+
data.tar.gz: 1569110d900cc87b345fe27ee1ce8b369ccec493d82f1e878e7e9b750fb1aefa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44ef27e0b165082ac1950b4a167978c5c1db7adfa6379ed578e3f60c2a2afe76686ed938586c8ab8831a90663ddc62bf19df9d90f9dbdab5d41cb41c4537f724
|
7
|
+
data.tar.gz: e69c500ae4c2263320a257e8ca0b397aa32ed4ba904fd0d118cfaaee92165d5ace558108cf8a5fb9f3432c0df4289ad108bc4ed788b9f439acf1799bae41642f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Remote Syslog Logger
|
2
2
|
|
3
|
-
This library providers an [ActiveSupport][] compatible logger that logs
|
3
|
+
This library providers an [ActiveSupport][] compatible logger that logs
|
4
4
|
directly to a remote syslogd via UDP.
|
5
5
|
|
6
6
|
[ActiveSupport]: http://as.rubyonrails.org/
|
@@ -8,23 +8,39 @@ directly to a remote syslogd via UDP.
|
|
8
8
|
|
9
9
|
# Installation
|
10
10
|
|
11
|
-
The easiest way to install `remote_syslog_logger` is with
|
11
|
+
The easiest way to install `remote_syslog_logger` is with Bundler. Add
|
12
|
+
`remote_syslog_logger` to your `Gemfile`.
|
13
|
+
|
14
|
+
If you are not using a `Gemfile`, run:
|
12
15
|
|
13
16
|
$ [sudo] gem install remote_syslog_logger
|
14
17
|
|
15
18
|
|
16
19
|
# Usage
|
17
20
|
|
18
|
-
|
19
21
|
Use from Rails:
|
20
22
|
|
21
|
-
config.logger = RemoteSyslogLogger.new('syslog.domain.com', 514,
|
23
|
+
config.logger = RemoteSyslogLogger.new('syslog.domain.com', 514,
|
24
|
+
:program => "rails-#{RAILS_ENV}",
|
25
|
+
:local_hostname => "optional_hostname")
|
26
|
+
|
27
|
+
With Rails 3+ if you want to use tagged logging wrap in a `TaggedLogging` instance:
|
22
28
|
|
29
|
+
config.logger = ActiveSupport::TaggedLogging.new(
|
30
|
+
RemoteSyslogLogger.new(
|
31
|
+
'syslog.domain.com', 514,
|
32
|
+
:program => "rails-#{RAILS_ENV}",
|
33
|
+
:local_hostname => "optional_hostname"
|
34
|
+
)
|
35
|
+
)
|
23
36
|
|
24
37
|
Use from Ruby:
|
25
38
|
|
39
|
+
require 'remote_syslog_logger'
|
26
40
|
$logger = RemoteSyslogLogger.new('syslog.domain.com', 514)
|
27
41
|
|
42
|
+
To point the logs to your local system, use `localhost` and ensure that
|
43
|
+
the system's syslog daemon is bound to `127.0.0.1`.
|
28
44
|
|
29
45
|
|
30
46
|
# Source
|
@@ -38,6 +54,65 @@ and cloned with:
|
|
38
54
|
$ git clone git://github.com/papertrail/remote_syslog_logger.git
|
39
55
|
|
40
56
|
|
57
|
+
# Limitations
|
58
|
+
|
59
|
+
If the specified host cannot be resolved, `syslog.domain.com` in the
|
60
|
+
example under the usage section above, `remote_syslog_logger` will block
|
61
|
+
for approximately 20 seconds before displaying an error. This could
|
62
|
+
result in the application failing to start or even stopping responding.
|
63
|
+
|
64
|
+
Workarounds for this include:
|
65
|
+
|
66
|
+
* use an IP address instead of a hostname.
|
67
|
+
* put a hosts entry in `/etc/hosts` or equivalent, so that DNS is not
|
68
|
+
actually consulted
|
69
|
+
* instead of logging directly to the network, write to a file and
|
70
|
+
transmit new entries with a standalone daemon like
|
71
|
+
[remote_syslog](https://github.com/papertrail/remote_syslog),
|
72
|
+
|
73
|
+
## Message length
|
74
|
+
|
75
|
+
All log lines are truncated to a maximum of 1024 characters. This restriction
|
76
|
+
comes from [RFC 3164 section 4.1][rfc-limit]:
|
77
|
+
|
78
|
+
> The total length of the packet MUST be 1024 bytes or less.
|
79
|
+
|
80
|
+
Additionally, the generally-accepted [MTU][] of the Internet is 1500 bytes, so
|
81
|
+
regardless of the RFC, UDP syslog packets longer than 1500 bytes would not
|
82
|
+
arrive. For details or to use TCP syslog for longer messages, see
|
83
|
+
[help.papertrailapp.com][troubleshoot].
|
84
|
+
|
85
|
+
There is a `max_size` option to override this restriction, but it should only be
|
86
|
+
used in extraordinary circumstances. Oversize messages are more likely to be
|
87
|
+
fragmented and lost, with some receivers rejecting them entirely.
|
88
|
+
|
89
|
+
[rfc-limit]: https://tools.ietf.org/html/rfc3164#section-4.1
|
90
|
+
[MTU]: (https://en.wikipedia.org/wiki/Maximum_transmission_unit)
|
91
|
+
[troubleshoot]: http://help.papertrailapp.com/kb/configuration/troubleshooting-remote-syslog-reachability/#message-length
|
92
|
+
|
93
|
+
|
94
|
+
## Default program name
|
95
|
+
|
96
|
+
By default, the `program` value is set to the name and ID of the invoking
|
97
|
+
process. For example, `puma[12345]` or `rack[3456]`.
|
98
|
+
|
99
|
+
The `program` value is used to populate the syslog "tag" field, must be 32
|
100
|
+
or fewer characters. In a few cases, an artifact of how the app is launched
|
101
|
+
may lead to a default `program` value longer than 32 characters. For example,
|
102
|
+
the `thin` Web server may generate a default `program` value such
|
103
|
+
as:
|
104
|
+
|
105
|
+
thin server (0.0.0.0:3001)[11179]
|
106
|
+
|
107
|
+
If this occurs, the following exception will be raised when a
|
108
|
+
`RemoteSyslogLogger` is instantiated:
|
109
|
+
|
110
|
+
Tag must not be longer than 32 characters (ArgumentError)
|
111
|
+
|
112
|
+
To remedy this, explicitly provide a `program` argument which is shorter than
|
113
|
+
32 characters. See [Usage](#usage).
|
114
|
+
|
115
|
+
|
41
116
|
# Contributing
|
42
117
|
|
43
118
|
Once you've made your great commits:
|
@@ -54,7 +129,7 @@ on coding standards, new features, etc.
|
|
54
129
|
|
55
130
|
# License
|
56
131
|
|
57
|
-
Copyright (c) 2011 Eric Lindvall. See [LICENSE][] for details.
|
132
|
+
Copyright (c) 2011-2016 Eric Lindvall. See [LICENSE][] for details.
|
58
133
|
|
59
134
|
|
60
135
|
[cb]: https://wiki.github.com/defunkt/resque/contributing
|
data/Rakefile
CHANGED
@@ -60,8 +60,8 @@ task :coverage do
|
|
60
60
|
sh "open coverage/index.html"
|
61
61
|
end
|
62
62
|
|
63
|
-
require '
|
64
|
-
|
63
|
+
require 'rdoc/task'
|
64
|
+
RDoc::Task.new do |rdoc|
|
65
65
|
rdoc.rdoc_dir = 'rdoc'
|
66
66
|
rdoc.title = "#{name} #{version}"
|
67
67
|
rdoc.rdoc_files.include('README*')
|
data/lib/remote_syslog_logger.rb
CHANGED
@@ -3,9 +3,9 @@ require 'remote_syslog_logger/udp_sender'
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
module RemoteSyslogLogger
|
6
|
-
VERSION = '1.0.
|
6
|
+
VERSION = '1.0.4'
|
7
7
|
|
8
8
|
def self.new(remote_hostname, remote_port, options = {})
|
9
9
|
Logger.new(RemoteSyslogLogger::UdpSender.new(remote_hostname, remote_port, options))
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -7,6 +7,7 @@ module RemoteSyslogLogger
|
|
7
7
|
@remote_hostname = remote_hostname
|
8
8
|
@remote_port = remote_port
|
9
9
|
@whinyerrors = options[:whinyerrors]
|
10
|
+
@max_size = options[:max_size]
|
10
11
|
|
11
12
|
@socket = UDPSocket.new
|
12
13
|
@packet = SyslogProtocol::Packet.new
|
@@ -26,7 +27,8 @@ module RemoteSyslogLogger
|
|
26
27
|
next if line =~ /^\s*$/
|
27
28
|
packet = @packet.dup
|
28
29
|
packet.content = line
|
29
|
-
@
|
30
|
+
payload = @max_size ? packet.assemble(@max_size) : packet.assemble
|
31
|
+
@socket.send(payload, 0, @remote_hostname, @remote_port)
|
30
32
|
rescue
|
31
33
|
$stderr.puts "#{self.class} error: #{$!.class}: #{$!}\nOriginal message: #{line}"
|
32
34
|
raise if @whinyerrors
|
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'remote_syslog_logger'
|
16
|
-
s.version = '1.0.
|
17
|
-
s.date = '
|
16
|
+
s.version = '1.0.4'
|
17
|
+
s.date = '2018-10-10'
|
18
18
|
# s.rubyforge_project = 'remote_syslog_logger'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/test/helper.rb
CHANGED
@@ -11,18 +11,18 @@ class TestRemoteSyslogLogger < Test::Unit::TestCase
|
|
11
11
|
@logger = RemoteSyslogLogger.new('127.0.0.1', @server_port)
|
12
12
|
@logger.info "This is a test"
|
13
13
|
|
14
|
-
message,
|
15
|
-
assert_match
|
14
|
+
message, _ = *@socket.recvfrom(1024)
|
15
|
+
assert_match "This is a test", message
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_logger_multiline
|
19
19
|
@logger = RemoteSyslogLogger.new('127.0.0.1', @server_port)
|
20
20
|
@logger.info "This is a test\nThis is the second line"
|
21
21
|
|
22
|
-
message,
|
23
|
-
assert_match
|
22
|
+
message, _ = *@socket.recvfrom(1024)
|
23
|
+
assert_match "This is a test", message
|
24
24
|
|
25
|
-
message,
|
26
|
-
assert_match
|
25
|
+
message, _ = *@socket.recvfrom(1024)
|
26
|
+
assert_match "This is the second line", message
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,47 +1,37 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_syslog_logger
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 1.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Eric Lindvall
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2018-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: syslog_protocol
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
27
17
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
33
20
|
type: :runtime
|
34
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
35
27
|
description: A ruby Logger that sends UDP directly to a remote syslog endpoint
|
36
28
|
email: eric@5stops.com
|
37
29
|
executables: []
|
38
|
-
|
39
30
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
31
|
+
extra_rdoc_files:
|
42
32
|
- README.md
|
43
33
|
- LICENSE
|
44
|
-
files:
|
34
|
+
files:
|
45
35
|
- Gemfile
|
46
36
|
- LICENSE
|
47
37
|
- README.md
|
@@ -51,39 +41,29 @@ files:
|
|
51
41
|
- remote_syslog_logger.gemspec
|
52
42
|
- test/helper.rb
|
53
43
|
- test/test_remote_syslog_logger.rb
|
54
|
-
has_rdoc: true
|
55
44
|
homepage: https://github.com/papertrail/remote_syslog_logger
|
56
45
|
licenses: []
|
57
|
-
|
46
|
+
metadata: {}
|
58
47
|
post_install_message:
|
59
|
-
rdoc_options:
|
60
|
-
- --charset=UTF-8
|
61
|
-
require_paths:
|
48
|
+
rdoc_options:
|
49
|
+
- "--charset=UTF-8"
|
50
|
+
require_paths:
|
62
51
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
|
65
|
-
requirements:
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
66
54
|
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
version: "0"
|
72
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
75
59
|
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
version: "0"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
81
62
|
requirements: []
|
82
|
-
|
83
63
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
64
|
+
rubygems_version: 2.7.6
|
85
65
|
signing_key:
|
86
66
|
specification_version: 2
|
87
67
|
summary: Ruby Logger that sends directly to a remote syslog endpoint
|
88
|
-
test_files:
|
68
|
+
test_files:
|
89
69
|
- test/test_remote_syslog_logger.rb
|