logging-rtail 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc4e9e5dfdd6a40e40713d3084a09fa303f0fb27
4
- data.tar.gz: 3dc9d2c14d07668cf3912f528f1197c4599a9827
3
+ metadata.gz: 62ba7df0170a9c1293a309313868d708ec1fe74c
4
+ data.tar.gz: 348d82de4d5c2be81b6256b20e2b67bfa2f2c528
5
5
  SHA512:
6
- metadata.gz: d016b3fe9ab2c153a73c8a49da6aaafa61c381c659086f70eee6354d732b6390cf57c59a77ee95e90f793d05080a02c076408243aa116d76c3061c3cb57f2430
7
- data.tar.gz: 9541536876b1b754f40552fd1f6e5abc07cdceed4674165a3a22d77f10a8efff7f7d2cb5c9d55cf1537ac11d5bf06ea7d2932627bf1608de6b4e9dcf4ea93e38
6
+ metadata.gz: 8c3f1f270c7f4808668dcc68ddec0c1e17e06f0f03fb54ed3eed7c75224c58ea9e5ada4ef55c1767840edec7b1c4b2b7a387f751f2ad63a616a80ad2808b99ec
7
+ data.tar.gz: aa701cef95c3edb696e66daf05bfab31b6f2bdbc1baa732e7757acf0c984f651d10c2f8f44f54bd69ad0f71f4b6b1b1045ae01eab85ed9bccd8c051b0630888c
data/README.md CHANGED
@@ -53,6 +53,20 @@ l.add_appenders(
53
53
  )
54
54
  ```
55
55
 
56
+ ### Omitting Timezone from the Timestamp
57
+
58
+ The Rtail server seems to output Timestamps in UTC uncomprimisingly, rather than localtime.
59
+ This can make it a little confusing when watching the logs if you don't live in the UK.
60
+
61
+ As a work-around, you can enable the option `omit_timezone` to the Rtail appender, and it will drop
62
+ TZ information from the Timestamp it sends to the Rtail server:
63
+
64
+ ```ruby
65
+ l.add_appenders(
66
+ Logging.appenders.rtail("Wild Test stream", omit_timezone: true)
67
+ )
68
+ ```
69
+
56
70
  ## Development
57
71
 
58
72
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
@@ -11,15 +11,21 @@ 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
15
+
14
16
  # Creates a new Rtail Appender that will use the given host and port
15
17
  # as the Rtail server destination.
16
18
  #
17
19
  # @param name [String] Stream ID to differentiate in the Rtail server
18
20
  # @param host [String] Host / IP of the Rtail server's UDP receiver (defaults to "localhost")
19
21
  # @param port [Integer] Port of the Rtail server's UDP receiver (defaults to 9999)
22
+ # @param omit_timezone [Boolean] When creating the time-stamp for a log entry, omit the time-zone specifier
20
23
  def initialize(name, opts = {})
21
24
  @host = opts.fetch(:host, 'localhost')
22
25
  @port = opts.fetch(:port, 9999)
26
+ # FIXME: Rtail Server needs to be fixed to allow log-time output in localtime, instead of UTC.
27
+ # For now, users may need to do this:
28
+ @omit_timezone = opts.fetch(:omit_timezone, false)
23
29
 
24
30
  fail ArgumentError, 'Empty host and port is not appropriate' unless host && !host.empty? && port
25
31
 
@@ -27,12 +33,6 @@ module Logging
27
33
  super(name, connect(@host, @port), opts.merge(auto_flushing: true))
28
34
  end
29
35
 
30
- def host
31
- @host.dup
32
- end
33
-
34
- attr_reader :port
35
-
36
36
  # Reopen the connection to the underlying logging destination. If the
37
37
  # connection is currently closed then it will be opened. If the connection
38
38
  # is currently open then it will be closed and immediately opened.
@@ -59,7 +59,8 @@ module Logging
59
59
  return self if @io.nil?
60
60
 
61
61
  str = str.force_encoding(encoding) if encoding && str.encoding != encoding
62
- @io.syswrite JSON.generate(id: name, timestamp: Time.now, content: str)
62
+ timestamp = omit_timezone ? Time.now.strftime('%FT%T') : Time.now.to_s
63
+ @io.syswrite JSON.generate(id: name, timestamp: timestamp, content: str)
63
64
 
64
65
  self
65
66
 
@@ -4,7 +4,7 @@ module Logging
4
4
  module Rtail
5
5
  extend self
6
6
 
7
- VERSION = '0.1.2'.freeze unless defined? VERSION
7
+ VERSION = '0.1.3'.freeze unless defined? VERSION
8
8
 
9
9
  # Initialiser for `little-plugger`:
10
10
  def initialize_rtail
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logging-rtail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will