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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62ba7df0170a9c1293a309313868d708ec1fe74c
4
- data.tar.gz: 348d82de4d5c2be81b6256b20e2b67bfa2f2c528
3
+ metadata.gz: 82fc4e27d31d913f1ba4b001656d9635781d9531
4
+ data.tar.gz: 66341c8e2a991c044a4a6bc352c4c7687ddee6a3
5
5
  SHA512:
6
- metadata.gz: 8c3f1f270c7f4808668dcc68ddec0c1e17e06f0f03fb54ed3eed7c75224c58ea9e5ada4ef55c1767840edec7b1c4b2b7a387f751f2ad63a616a80ad2808b99ec
7
- data.tar.gz: aa701cef95c3edb696e66daf05bfab31b6f2bdbc1baa732e7757acf0c984f651d10c2f8f44f54bd69ad0f71f4b6b1b1045ae01eab85ed9bccd8c051b0630888c
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
- @io.syswrite JSON.generate(id: name, timestamp: timestamp, content: str)
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
 
@@ -4,7 +4,7 @@ module Logging
4
4
  module Rtail
5
5
  extend self
6
6
 
7
- VERSION = '0.1.3'.freeze unless defined? VERSION
7
+ VERSION = '0.1.4'.freeze unless defined? VERSION
8
8
 
9
9
  # Initialiser for `little-plugger`:
10
10
  def initialize_rtail
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.3
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-10-15 00:00:00.000000000 Z
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.8
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