logging-rtail 0.1.3 → 0.1.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 +4 -4
- data/lib/logging/appenders/rtail.rb +9 -2
- data/lib/logging/plugins/rtail.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82fc4e27d31d913f1ba4b001656d9635781d9531
|
4
|
+
data.tar.gz: 66341c8e2a991c044a4a6bc352c4c7687ddee6a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc4d2c659eaf593e146343c7a5d369d8a4e224c0fbc8e0f5cb77d93396e2a0d65ed63487aaa992a0b1cde7af25cf5c8149537666696e5bd5612a3a126641a417
|
7
|
+
data.tar.gz: 092606896f445b0d1e53ad7654b8f50b8a6ca637c725c9dc79494ccbe356a636675425fd4057d893d466332f106af671277609d9e99ccae1f5a07f5be72bb782
|
@@ -11,7 +11,7 @@ module Logging
|
|
11
11
|
|
12
12
|
# This class provides an Appender that can write to a Rtail service over UDP.
|
13
13
|
class Rtail < ::Logging::Appenders::IO
|
14
|
-
attr_reader :host, :port, :omit_timezone
|
14
|
+
attr_reader :host, :port, :omit_timezone, :split_newline
|
15
15
|
|
16
16
|
# Creates a new Rtail Appender that will use the given host and port
|
17
17
|
# as the Rtail server destination.
|
@@ -20,12 +20,15 @@ module Logging
|
|
20
20
|
# @param host [String] Host / IP of the Rtail server's UDP receiver (defaults to "localhost")
|
21
21
|
# @param port [Integer] Port of the Rtail server's UDP receiver (defaults to 9999)
|
22
22
|
# @param omit_timezone [Boolean] When creating the time-stamp for a log entry, omit the time-zone specifier
|
23
|
+
# @param split_newline [Boolean] Split a logging string by newlines, and send each independently to the rtail server
|
24
|
+
# NB: You often have to do this, as the rtail server sometimes "squishes" such lines up
|
23
25
|
def initialize(name, opts = {})
|
24
26
|
@host = opts.fetch(:host, 'localhost')
|
25
27
|
@port = opts.fetch(:port, 9999)
|
26
28
|
# FIXME: Rtail Server needs to be fixed to allow log-time output in localtime, instead of UTC.
|
27
29
|
# For now, users may need to do this:
|
28
30
|
@omit_timezone = opts.fetch(:omit_timezone, false)
|
31
|
+
@split_newline = opts.fetch(:split_newline, true)
|
29
32
|
|
30
33
|
fail ArgumentError, 'Empty host and port is not appropriate' unless host && !host.empty? && port
|
31
34
|
|
@@ -60,7 +63,11 @@ module Logging
|
|
60
63
|
|
61
64
|
str = str.force_encoding(encoding) if encoding && str.encoding != encoding
|
62
65
|
timestamp = omit_timezone ? Time.now.strftime('%FT%T') : Time.now.to_s
|
63
|
-
|
66
|
+
lines = split_newline ? str.split("\n") : [str]
|
67
|
+
|
68
|
+
lines.each do |line|
|
69
|
+
@io.syswrite JSON.generate(id: name, timestamp: timestamp, content: line)
|
70
|
+
end
|
64
71
|
|
65
72
|
self
|
66
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logging-rtail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.4.
|
149
|
+
rubygems_version: 2.4.5.1
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: An appender for the Logging gem that sends messages to an Rtail server
|