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 +4 -4
- data/README.md +14 -0
- data/lib/logging/appenders/rtail.rb +8 -7
- data/lib/logging/plugins/rtail.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62ba7df0170a9c1293a309313868d708ec1fe74c
|
4
|
+
data.tar.gz: 348d82de4d5c2be81b6256b20e2b67bfa2f2c528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|