franz 1.5.4 → 1.5.5

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: 05a395b2d10064db126d23875c069f0a4ca69ec3
4
- data.tar.gz: 20fe5d0196a3172f3647161e43f8bf07638d9ae1
3
+ metadata.gz: 002cdbcf468f836461f433dcac17b46bae72d6d4
4
+ data.tar.gz: 6d8ff2477e002e1430ea7e5f6123ac0bad96ef27
5
5
  SHA512:
6
- metadata.gz: a629498d8e9865d1df45ba2aa9ae3cd21cd9f285057ca1684cb7b2ea47bcfda0588456c10655aa183a668f1d85f665a41f014abf4628e43aa2fb25de35af44a2
7
- data.tar.gz: f0859c346bd2e5703085f790de79afb29b0ae7e68e77ae1a21291572dae304681dac6fa9d9f17b3b3e7fd0538a44a65a15f5a9a14fac1d4fa8a1a6e680824a03
6
+ metadata.gz: 9df6ecca70bdc52d7b6d5e307612a911ded05ecc925a3771be33eff5f9fe4ac6820bcf2550e97c2b4f876ff4219f09f5222174034be7fa197fd4a7c63b2ecd7a
7
+ data.tar.gz: 067961fe1616a5244781b4ddc248cbcc4a549ea2f183485b79aae6831684b927a27f724f05afb089b3bb977a6bf2975e9e9d65d040a545be88f764bd3ab46196
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.4
1
+ 1.5.5
data/lib/franz/logger.rb CHANGED
@@ -16,16 +16,16 @@ module Franz
16
16
  end
17
17
  end
18
18
 
19
- # A powerful, colorful logger for Franz.
19
+ # A colorful JSON logger for Franz.
20
20
  class Logger < Logger
21
21
  # Maps each log level to a unique combination of fore- and background colors
22
22
  SEVERITY_COLORS = {
23
- 'DEBUG' => [ :blue, :default ],
24
- 'INFO' => [ :green, :default ],
25
- 'WARN' => [ :yellow, :default ],
26
- 'ERROR' => [ :red, :default ],
27
- 'FATAL' => [ :red, :black ],
28
- 'TRACE' => [ :magenta, :default ]
23
+ 'debug' => [ :blue, :default ],
24
+ 'info' => [ :green, :default ],
25
+ 'warn' => [ :yellow, :default ],
26
+ 'error' => [ :red, :default ],
27
+ 'fatal' => [ :red, :black ],
28
+ 'trace' => [ :magenta, :default ]
29
29
  }
30
30
 
31
31
  # Create a new, colorful logger.
@@ -44,46 +44,24 @@ module Franz
44
44
 
45
45
  private
46
46
  def format colorize
47
- short_format = "%s\n"
48
- long_format = "%s [%s] %s -- %s\n"
49
-
50
47
  self.formatter = proc do |severity, datetime, _, message|
51
- if colorize
52
- if level == 1
53
- event = {
54
- level: severity.downcase,
55
- timestamp: Time.now.iso8601(6)
56
- }.merge(message)
57
- JSON::generate(event).colorize(
58
- color: SEVERITY_COLORS[severity.to_s][0],
59
- background: SEVERITY_COLORS[severity.to_s][1]
60
- ) + "\n"
61
- else
62
- long_format.colorize(
63
- color: SEVERITY_COLORS[severity.to_s][0],
64
- background: SEVERITY_COLORS[severity.to_s][1]
65
- ) % [
66
- severity,
67
- datetime.iso8601(6),
68
- File::basename(caller[4]),
69
- message
70
- ]
71
- end
72
- else # plain
73
- if level == 1
74
- event = {
75
- level: severity.downcase,
76
- timestamp: Time.now.iso8601(6)
77
- }.merge(message)
78
- JSON::generate(event) + "\n"
79
- else
80
- long_format % [
81
- severity,
82
- datetime.iso8601(6),
83
- File::basename(caller[4]),
84
- message
85
- ]
86
- end
48
+
49
+ message = { message: message } unless message.is_a? Hash
50
+
51
+ event = {
52
+ severity: severity.downcase!,
53
+ timestamp: datetime.iso8601(6),
54
+ marker: File::basename(caller[4])
55
+ }.merge(message)
56
+
57
+ if colorize # console output
58
+ event = JSON::pretty_generate(event) + "\n"
59
+ event.colorize \
60
+ color: SEVERITY_COLORS[severity][0],
61
+ background: SEVERITY_COLORS[severity][1]
62
+
63
+ else # logging to file
64
+ event = JSON::generate(event) + "\n"
87
65
  end
88
66
  end
89
67
  end
data/lib/franz/output.rb CHANGED
@@ -37,7 +37,8 @@ module Franz
37
37
  rabbit = Bunny.new opts[:output][:connection].merge({
38
38
  network_recovery_interval: 10.0,
39
39
  continuation_timeout: 10_000,
40
- threaded: false
40
+ threaded: false,
41
+ logger: @logger
41
42
  })
42
43
 
43
44
  rabbit.start
data/lib/franz/tail.rb CHANGED
@@ -8,7 +8,7 @@ module Franz
8
8
  # Tail receives low-level file events from a Watch and handles the actual
9
9
  # reading of files, providing a stream of lines.
10
10
  class Tail
11
- ERR_NIL_READ = 1
11
+ ERR_BUFFER_FULL = 1
12
12
  ERR_INVALID_EVENT = 2
13
13
  ERR_INCOMPLETE_READ = 3
14
14
 
@@ -93,42 +93,23 @@ module Franz
93
93
  spread: spread
94
94
  end
95
95
 
96
- nil_reads = 0
97
-
98
96
  loop do
99
97
  break if @cursors[path] >= size
100
98
 
101
99
  begin
102
100
  data = IO::read path, @block_size, @cursors[path]
103
101
  rescue EOFError, Errno::ENOENT
104
- next
102
+ data = nil
105
103
  end
106
104
 
107
- # Handle issue with IO::read, which seems to return nil when
108
- # the file in question has been rotated. In such a case, we'll
109
- # just reset the cursor and bail; hopefully we'll get a
110
- # "rotated" event from Watch in the near future.
111
- if data.nil?
112
- nil_reads += 1
113
-
105
+ if data.nil? # Old file went away
114
106
  log.warn \
115
107
  event: 'nil read',
116
108
  path: path,
117
109
  size: size,
118
110
  cursor: @cursors[path],
119
111
  spread: (size - @cursors[path])
120
-
121
- if nil_reads >= 100
122
- log.error \
123
- event: 'nil read loop',
124
- path: path,
125
- size: size,
126
- cursor: @cursors[path],
127
- spread: (size - @cursors[path])
128
- @cursors[path] = 0
129
- return
130
- end
131
-
112
+ @cursors[path] = 0
132
113
  next
133
114
  end
134
115
 
@@ -145,7 +126,7 @@ module Franz
145
126
  size: size,
146
127
  cursor: @cursors[path],
147
128
  spread: (size - @cursors[path])
148
- exit ERR_NIL_READ
129
+ exit ERR_BUFFER_FULL
149
130
  end
150
131
 
151
132
  @cursors[path] += data_size
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: franz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny