fluentd 1.9.3 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue-auto-closer.yml +12 -0
  3. data/CHANGELOG.md +182 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/README.md +4 -0
  6. data/docs/SECURITY_AUDIT.pdf +0 -0
  7. data/lib/fluent/command/debug.rb +1 -0
  8. data/lib/fluent/command/fluentd.rb +25 -1
  9. data/lib/fluent/config.rb +1 -0
  10. data/lib/fluent/daemonizer.rb +88 -0
  11. data/lib/fluent/log.rb +45 -6
  12. data/lib/fluent/match.rb +1 -1
  13. data/lib/fluent/msgpack_factory.rb +13 -6
  14. data/lib/fluent/plugin/buffer.rb +2 -2
  15. data/lib/fluent/plugin/in_dummy.rb +3 -3
  16. data/lib/fluent/plugin/in_forward.rb +2 -2
  17. data/lib/fluent/plugin/in_gc_stat.rb +16 -0
  18. data/lib/fluent/plugin/in_http.rb +146 -75
  19. data/lib/fluent/plugin/in_monitor_agent.rb +1 -1
  20. data/lib/fluent/plugin/in_syslog.rb +4 -4
  21. data/lib/fluent/plugin/in_tail.rb +40 -31
  22. data/lib/fluent/plugin/in_tail/position_file.rb +23 -6
  23. data/lib/fluent/plugin/in_unix.rb +77 -77
  24. data/lib/fluent/plugin/out_copy.rb +1 -1
  25. data/lib/fluent/plugin/out_file.rb +1 -1
  26. data/lib/fluent/plugin/out_forward.rb +25 -22
  27. data/lib/fluent/plugin/out_forward/handshake_protocol.rb +4 -0
  28. data/lib/fluent/plugin/out_forward/load_balancer.rb +1 -1
  29. data/lib/fluent/plugin/out_http.rb +15 -2
  30. data/lib/fluent/plugin/parser_multiline.rb +1 -1
  31. data/lib/fluent/plugin/parser_syslog.rb +303 -62
  32. data/lib/fluent/plugin/sd_file.rb +1 -0
  33. data/lib/fluent/plugin/sd_srv.rb +135 -0
  34. data/lib/fluent/plugin_helper/cert_option.rb +15 -2
  35. data/lib/fluent/plugin_helper/child_process.rb +3 -2
  36. data/lib/fluent/plugin_helper/record_accessor.rb +14 -0
  37. data/lib/fluent/plugin_helper/server.rb +3 -1
  38. data/lib/fluent/plugin_helper/service_discovery.rb +7 -0
  39. data/lib/fluent/plugin_helper/service_discovery/manager.rb +8 -0
  40. data/lib/fluent/plugin_helper/socket.rb +20 -2
  41. data/lib/fluent/plugin_helper/socket_option.rb +21 -3
  42. data/lib/fluent/supervisor.rb +21 -9
  43. data/lib/fluent/system_config.rb +2 -1
  44. data/lib/fluent/test/filter_test.rb +2 -2
  45. data/lib/fluent/test/output_test.rb +3 -3
  46. data/lib/fluent/version.rb +1 -1
  47. data/test/command/test_fluentd.rb +71 -12
  48. data/test/config/test_system_config.rb +2 -0
  49. data/test/helper.rb +2 -2
  50. data/test/plugin/in_tail/test_fifo.rb +121 -0
  51. data/test/plugin/in_tail/test_io_handler.rb +132 -0
  52. data/test/plugin/in_tail/test_position_file.rb +25 -1
  53. data/test/plugin/out_forward/test_handshake_protocol.rb +10 -1
  54. data/test/plugin/out_forward/test_load_balancer.rb +46 -0
  55. data/test/plugin/test_buf_file.rb +3 -1
  56. data/test/plugin/test_buffer.rb +20 -0
  57. data/test/plugin/test_compressable.rb +7 -4
  58. data/test/plugin/test_in_dummy.rb +12 -14
  59. data/test/plugin/test_in_forward.rb +2 -2
  60. data/test/plugin/test_in_gc_stat.rb +24 -1
  61. data/test/plugin/test_in_http.rb +57 -0
  62. data/test/plugin/test_in_syslog.rb +16 -1
  63. data/test/plugin/test_in_tail.rb +43 -20
  64. data/test/plugin/test_in_unix.rb +128 -73
  65. data/test/plugin/test_out_forward.rb +39 -3
  66. data/test/plugin/test_out_http.rb +38 -0
  67. data/test/plugin/test_out_null.rb +1 -1
  68. data/test/plugin/test_output_as_buffered_retries.rb +12 -4
  69. data/test/plugin/test_output_as_buffered_secondary.rb +9 -1
  70. data/test/plugin/test_parser_syslog.rb +106 -46
  71. data/test/plugin/test_sd_file.rb +17 -0
  72. data/test/plugin/test_sd_srv.rb +230 -0
  73. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +19 -0
  74. data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +27 -0
  75. data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +20 -0
  76. data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +27 -0
  77. data/test/plugin_helper/data/cert/cert_chains/cert.pem +40 -0
  78. data/test/plugin_helper/data/cert/generate_cert.rb +38 -0
  79. data/test/plugin_helper/http_server/test_app.rb +1 -1
  80. data/test/plugin_helper/http_server/test_route.rb +1 -1
  81. data/test/plugin_helper/test_cert_option.rb +2 -0
  82. data/test/plugin_helper/test_child_process.rb +20 -3
  83. data/test/plugin_helper/test_http_server_helper.rb +2 -2
  84. data/test/plugin_helper/test_record_accessor.rb +41 -0
  85. data/test/plugin_helper/test_server.rb +1 -1
  86. data/test/plugin_helper/test_service_discovery.rb +37 -4
  87. data/test/plugin_helper/test_socket.rb +131 -0
  88. data/test/test_daemonizer.rb +91 -0
  89. data/test/test_log.rb +44 -0
  90. data/test/test_msgpack_factory.rb +18 -0
  91. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d67b7f6379705086047bb2d3adb34fc3c1dbb3c29b1dcd901b9cac62da28978f
4
- data.tar.gz: ca8ee48ac0a2d435a87f189812e48c09d9d2947c06b6c2d3ce0e35a7e4c126e1
3
+ metadata.gz: a2688d527009c35ea2a5c989a2b3face3685a8ebec599dc710ebf781af6239ae
4
+ data.tar.gz: 804badf95082207f2851680fbb34fd414769abd8265fd1e4a2d7e7e90549c063
5
5
  SHA512:
6
- metadata.gz: ab9d1deb64f93efa57575b28d2f72eb8ad4ef1874a4d86d6cdf38110968d3b7ea18773e658589151d338d6cc6b24187468c2864fa65616f6dbeb483fbe7bf600
7
- data.tar.gz: 147c88ed0e30a82f2b8e72cb6600737c9c44a83eecb1d974d5dc26634918bfb725e813ca9f65d56689067c979e1f488f29a2c899dafaa41ea9128ad552f285d6
6
+ metadata.gz: b83ee8e06598b3393376de10e1660e58bbdc04fe5bc6f4f957d1701b319e043e50504ea5adfe2d3e32321492a89f8e4d3fcdc51bd00c5f545518cc8fbec08bb6
7
+ data.tar.gz: 57ec086faf5ff26513175213e7221930c1e7a5c5517c97fadda97b02013b5ea126fc1f650477b34d464d6f0287077d62eaf7e7f6afec897fb6f060d72e5bc077
@@ -0,0 +1,12 @@
1
+ name: Autocloser
2
+ on: [issues]
3
+ jobs:
4
+ autoclose:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - name: Autoclose issues that did not follow issue template
8
+ uses: roots/issue-closer-action@v1.1
9
+ with:
10
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
11
+ issue-close-message: "@${issue.user.login} this issue was automatically closed because it did not follow the issue template"
12
+ issue-pattern: "(.*Describe the bug.*)|(.*Is your feature request related to a problem.*)"
@@ -1,3 +1,185 @@
1
+ # v1.11
2
+
3
+ ## Release v1.11.1 - 2020/06/22
4
+
5
+ ### Enhancement
6
+
7
+ * in_http: Add `dump_error_log` parameter
8
+ https://github.com/fluent/fluentd/pull/3035
9
+ * in_http: Improve time field handling
10
+ https://github.com/fluent/fluentd/pull/3046
11
+ * Refactoring code
12
+ https://github.com/fluent/fluentd/pull/3047
13
+
14
+ ### Bug fix
15
+
16
+ * in_tail: Use actual path instead of based pattern for ignore list
17
+ https://github.com/fluent/fluentd/pull/3042
18
+ * child_process helper: Fix child process failure due to SIGPIPE if the command uses stdout
19
+ https://github.com/fluent/fluentd/pull/3044
20
+
21
+ ## Release v1.11.0 - 2020/06/04
22
+
23
+ ### New feature
24
+
25
+ * in_unix: Use v1 API
26
+ https://github.com/fluent/fluentd/pull/2992
27
+
28
+ ### Enhancement
29
+
30
+ * parser_syslog: Support any `time_format` for RFC3164 string parser
31
+ https://github.com/fluent/fluentd/pull/3014
32
+ * parser_syslog: Add new parser for RFC5424
33
+ https://github.com/fluent/fluentd/pull/3015
34
+ * Refactoring code
35
+ https://github.com/fluent/fluentd/pull/3019
36
+
37
+ ### Bug fix
38
+
39
+ * in_gc_stat: Add `use_symbol_keys` parameter to emit string key record
40
+ https://github.com/fluent/fluentd/pull/3008
41
+
42
+ # v1.10
43
+
44
+ ## Release v1.10.4 - 2020/05/12
45
+
46
+ ### Enhancement
47
+
48
+ * out_http: Support single json array payload
49
+ https://github.com/fluent/fluentd/pull/2973
50
+ * Refactoring
51
+ https://github.com/fluent/fluentd/pull/2988
52
+
53
+ ### Bug fix
54
+
55
+ * supervisor: Call `File.umask(0)` for standalone worker
56
+ https://github.com/fluent/fluentd/pull/2987
57
+ * out_forward: Fix ZeroDivisionError issue with `weight 0`
58
+ https://github.com/fluent/fluentd/pull/2989
59
+
60
+ ## Release v1.10.3 - 2020/05/01
61
+
62
+ ### Enhancement
63
+
64
+ * record_accessor: Add `set` method
65
+ https://github.com/fluent/fluentd/pull/2977
66
+ * config: Ruby DSL format is deprecated
67
+ https://github.com/fluent/fluentd/pull/2958
68
+ * Refactor code
69
+ https://github.com/fluent/fluentd/pull/2961
70
+ https://github.com/fluent/fluentd/pull/2962
71
+ https://github.com/fluent/fluentd/pull/2965
72
+ https://github.com/fluent/fluentd/pull/2966
73
+ https://github.com/fluent/fluentd/pull/2978
74
+
75
+ ### Bug fix
76
+
77
+ * out_forward: Disable `linger_timeout` setting on Windows
78
+ https://github.com/fluent/fluentd/pull/2959
79
+ * out_forward: Fix warning of service discovery manager when fluentd stops
80
+ https://github.com/fluent/fluentd/pull/2974
81
+
82
+ ## Release v1.10.2 - 2020/04/15
83
+
84
+ ### Enhancement
85
+
86
+ * out_copy: Add plugin_id to log message
87
+ https://github.com/fluent/fluentd/pull/2934
88
+ * socket: Allow cert chains in mutual auth
89
+ https://github.com/fluent/fluentd/pull/2930
90
+ * system: Add ignore_repeated_log_interval parameter
91
+ https://github.com/fluent/fluentd/pull/2937
92
+ * windows: Allow to launch fluentd from whitespace included path
93
+ https://github.com/fluent/fluentd/pull/2920
94
+ * Refactor code
95
+ https://github.com/fluent/fluentd/pull/2935
96
+ https://github.com/fluent/fluentd/pull/2936
97
+ https://github.com/fluent/fluentd/pull/2938
98
+ https://github.com/fluent/fluentd/pull/2939
99
+ https://github.com/fluent/fluentd/pull/2946
100
+
101
+ ### Bug fix
102
+
103
+ * in_syslog: Fix octet-counting mode bug
104
+ https://github.com/fluent/fluentd/pull/2942
105
+ * out_forward: Create timer for purging obsolete sockets when keepalive_timeout is not set
106
+ https://github.com/fluent/fluentd/pull/2943
107
+ * out_forward: Need authentication when sending tcp heartbeat with keepalive
108
+ https://github.com/fluent/fluentd/pull/2945
109
+ * command: Fix fluent-debug start failure
110
+ https://github.com/fluent/fluentd/pull/2948
111
+ * command: Fix regression of supervisor's worker and `--daemon` combo
112
+ https://github.com/fluent/fluentd/pull/2950
113
+
114
+ ## Release v1.10.1 - 2020/04/02
115
+
116
+ ### Enhancement
117
+
118
+ * command: `--daemon` and `--no-supervisor` now work together
119
+ https://github.com/fluent/fluentd/pull/2912
120
+ * Refactor code
121
+ https://github.com/fluent/fluentd/pull/2913
122
+
123
+ ### Bug fix
124
+
125
+ * in_tail: `Fix pos_file_compaction_interval` parameter type
126
+ https://github.com/fluent/fluentd/pull/2921
127
+ * in_tail: Fix seek position update after compaction
128
+ https://github.com/fluent/fluentd/pull/2922
129
+ * parser_syslog: Fix regression in the `with_priority` and RFC5424 case
130
+ https://github.com/fluent/fluentd/pull/2923
131
+
132
+ ### Misc
133
+
134
+ * Add document for security audit
135
+ https://github.com/fluent/fluentd/pull/2911
136
+
137
+ ## Release v1.10.0 - 2020/03/24
138
+
139
+ ### New feature
140
+
141
+ * sd plugin: Add SRV record plugin
142
+ https://github.com/fluent/fluentd/pull/2876
143
+
144
+ ### Enhancement
145
+
146
+ * server: Add `cert_verifier` parameter for TLS transport
147
+ https://github.com/fluent/fluentd/pull/2888
148
+ * parser_syslog: Support customized time format
149
+ https://github.com/fluent/fluentd/pull/2886
150
+ * in_dummy: Delete `suspend` parameter
151
+ https://github.com/fluent/fluentd/pull/2897
152
+ * Refactor code
153
+ https://github.com/fluent/fluentd/pull/2858
154
+ https://github.com/fluent/fluentd/pull/2862
155
+ https://github.com/fluent/fluentd/pull/2864
156
+ https://github.com/fluent/fluentd/pull/2869
157
+ https://github.com/fluent/fluentd/pull/2870
158
+ https://github.com/fluent/fluentd/pull/2874
159
+ https://github.com/fluent/fluentd/pull/2881
160
+ https://github.com/fluent/fluentd/pull/2885
161
+ https://github.com/fluent/fluentd/pull/2894
162
+ https://github.com/fluent/fluentd/pull/2896
163
+ https://github.com/fluent/fluentd/pull/2898
164
+ https://github.com/fluent/fluentd/pull/2899
165
+ https://github.com/fluent/fluentd/pull/2900
166
+ https://github.com/fluent/fluentd/pull/2901
167
+ https://github.com/fluent/fluentd/pull/2906
168
+
169
+ ### Bug fix
170
+
171
+ * out_forward: windows: Permit to specify `linger_timeout`
172
+ https://github.com/fluent/fluentd/pull/2868
173
+ * parser_syslog: Fix syslog format detection
174
+ https://github.com/fluent/fluentd/pull/2879
175
+ * buffer: Fix `available_buffer_space_ratio` calculation
176
+ https://github.com/fluent/fluentd/pull/2882
177
+ * tls: Support CRLF based X.509 certificates
178
+ https://github.com/fluent/fluentd/pull/2890
179
+ * msgpack_factory mixin: Fix performance penalty for deprecation log
180
+ https://github.com/fluent/fluentd/pull/2903
181
+
182
+
1
183
  # v1.9
2
184
 
3
185
  ## Release v1.9.3 - 2020/03/05
@@ -24,7 +24,7 @@ If you find a bug of Fluentd or a mistake in the documentation, you can help us
24
24
  submitting an issue to Fluentd. Even better you can submit a Pull Request with a fix.
25
25
 
26
26
  * **Fluentd**: Use [fluentd](https://github.com/fluent/fluentd) repository. Fill issue template.
27
- * **Documentation**: Use [fluentd-docs](https://github.com/fluent/fluentd-docs-gitbook) repository.
27
+ * **Documentation**: Use [fluentd documentation](https://github.com/fluent/fluentd-docs-gitbook) repository.
28
28
 
29
29
  If you find a bug of 3rd party plugins, please submit an issue to each plugin repository.
30
30
  And use [omnibus-td-agent](https://github.com/treasure-data/omnibus-td-agent) repository for td-agent related issues.
data/README.md CHANGED
@@ -81,6 +81,10 @@ You can run specified test via `TEST` environment variable:
81
81
  - Copyright: 2011-2019 Fluentd Authors
82
82
  - License: Apache License, Version 2.0
83
83
 
84
+ ## Security
85
+
86
+ A third party security audit was performed by Cure53, you can see the full report [here](docs/SECURITY_AUDIT.pdf).
87
+
84
88
  ## Contributors:
85
89
 
86
90
  Patches contributed by [great developers](https://github.com/fluent/fluentd/contributors).
Binary file
@@ -61,6 +61,7 @@ else
61
61
  end
62
62
 
63
63
  require 'fluent/log'
64
+ require 'fluent/env'
64
65
  require 'fluent/engine'
65
66
  require 'fluent/system_config'
66
67
  require 'serverengine'
@@ -185,6 +185,10 @@ if Fluent.windows?
185
185
  opts[:regwinsvcautostart] = s
186
186
  }
187
187
 
188
+ op.on('--[no-]reg-winsvc-delay-start', "Automatically start the Windows Service at boot with delay. (only effective with '--reg-winsvc i' and '--reg-winsvc-auto-start') (Windows only)") {|s|
189
+ opts[:regwinsvcdelaystart] = s
190
+ }
191
+
188
192
  op.on('--reg-winsvc-fluentdopt OPTION', "specify fluentd option parameters for Windows Service. (Windows only)") {|s|
189
193
  opts[:fluentdopt] = s
190
194
  }
@@ -285,6 +289,13 @@ if winsvcinstmode = opts[:regwinsvc]
285
289
  dependencies: [""],
286
290
  display_name: opts[:winsvc_display_name]
287
291
  )
292
+
293
+ if opts[:regwinsvcdelaystart]
294
+ Service.configure(
295
+ service_name: opts[:winsvc_name],
296
+ delayed_start: true
297
+ )
298
+ end
288
299
  when 'u'
289
300
  if Service.status(opts[:winsvc_name]).current_state != 'stopped'
290
301
  begin
@@ -335,5 +346,18 @@ else
335
346
  end
336
347
  worker = Fluent::Supervisor.new(opts)
337
348
  worker.configure
338
- worker.run_worker
349
+
350
+ if opts[:daemonize] && opts[:standalone_worker]
351
+ require 'fluent/daemonizer'
352
+ args = ARGV.dup
353
+ i = args.index('--daemon')
354
+ args.delete_at(i + 1) # value of --daemon
355
+ args.delete_at(i) # --daemon itself
356
+
357
+ Fluent::Daemonizer.daemonize(opts[:daemonize], args) do
358
+ worker.run_worker
359
+ end
360
+ else
361
+ worker.run_worker
362
+ end
339
363
  end
@@ -62,6 +62,7 @@ module Fluent
62
62
  Parser.parse(str, fname, basepath)
63
63
  when :ruby
64
64
  require 'fluent/config/dsl'
65
+ $log.warn("Ruby DSL configuration format is deprecated. Please use original configuration format. https://docs.fluentd.org/configuration/config-file")
65
66
  Config::DSL::Parser.parse(str, File.join(basepath, fname))
66
67
  else
67
68
  raise "[BUG] unknown configuration parser specification:'#{parser}'"
@@ -0,0 +1,88 @@
1
+ #
2
+ # Fluentd
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'fluent/config/error'
18
+
19
+ module Fluent
20
+ class Daemonizer
21
+ def self.daemonize(pid_path, args = [], &block)
22
+ new.daemonize(pid_path, args, &block)
23
+ end
24
+
25
+ def daemonize(pid_path, args = [])
26
+ pid_fullpath = File.absolute_path(pid_path)
27
+ check_pidfile(pid_fullpath)
28
+
29
+ begin
30
+ Process.daemon(false, false)
31
+
32
+ File.write(pid_fullpath, Process.pid.to_s)
33
+
34
+ # install signal and set process name are performed by supervisor
35
+ install_at_exit_handlers(pid_fullpath)
36
+
37
+ yield
38
+ rescue NotImplementedError
39
+ daemonize_with_spawn(pid_fullpath, args)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def daemonize_with_spawn(pid_fullpath, args)
46
+ pid = Process.spawn(*['fluentd'].concat(args))
47
+
48
+ File.write(pid_fullpath, pid.to_s)
49
+
50
+ pid
51
+ end
52
+
53
+ def check_pidfile(pid_path)
54
+ if File.exist?(pid_path)
55
+ if !File.readable?(pid_path) || !File.writable?(pid_path)
56
+ raise Fluent::ConfigError, "Cannot access pid file: #{pid_path}"
57
+ end
58
+
59
+ pid =
60
+ begin
61
+ Integer(File.read(pid_path), 10)
62
+ rescue TypeError, ArgumentError
63
+ return # ignore
64
+ end
65
+
66
+ begin
67
+ Process.kill(0, pid)
68
+ raise Fluent::ConfigError, "pid(#{pid}) is running"
69
+ rescue Errno::EPERM
70
+ raise Fluent::ConfigError, "pid(#{pid}) is running"
71
+ rescue Errno::ESRCH
72
+ end
73
+ else
74
+ unless File.writable?(File.dirname(pid_path))
75
+ raise Fluent::ConfigError, "Cannot access directory for pid file: #{File.dirname(pid_path)}"
76
+ end
77
+ end
78
+ end
79
+
80
+ def install_at_exit_handlers(pidfile)
81
+ at_exit do
82
+ if File.exist?(pidfile)
83
+ File.delete(pidfile)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -112,6 +112,7 @@ module Fluent
112
112
  @optional_attrs = nil
113
113
 
114
114
  @suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
115
+ @ignore_repeated_log_interval = opts[:ignore_repeated_log_interval]
115
116
 
116
117
  @process_type = opts[:process_type] # :supervisor, :worker0, :workers Or :standalone
117
118
  @process_type ||= :standalone # to keep behavior of existing code
@@ -139,7 +140,8 @@ module Fluent
139
140
  dl_opts = {}
140
141
  dl_opts[:log_level] = @level - 1
141
142
  logger = ServerEngine::DaemonLogger.new(@out, dl_opts)
142
- clone = self.class.new(logger, suppress_repeated_stacktrace: @suppress_repeated_stacktrace, process_type: @process_type, worker_id: @worker_id)
143
+ clone = self.class.new(logger, suppress_repeated_stacktrace: @suppress_repeated_stacktrace, process_type: @process_type,
144
+ worker_id: @worker_id, ignore_repeated_log_interval: @ignore_repeated_log_interval)
143
145
  clone.format = @format
144
146
  clone.time_format = @time_format
145
147
  clone.log_event_enabled = @log_event_enabled
@@ -149,7 +151,7 @@ module Fluent
149
151
 
150
152
  attr_reader :format
151
153
  attr_reader :time_format
152
- attr_accessor :log_event_enabled
154
+ attr_accessor :log_event_enabled, :ignore_repeated_log_interval
153
155
  attr_accessor :out
154
156
  attr_accessor :level
155
157
  attr_accessor :optional_header, :optional_attrs
@@ -278,6 +280,7 @@ module Fluent
278
280
  return if skipped_type?(type)
279
281
  args << block.call if block
280
282
  time, msg = event(:trace, args)
283
+ return if time.nil?
281
284
  puts [@color_trace, @formatter.call(type, time, LEVEL_TRACE, msg), @color_reset].join
282
285
  rescue
283
286
  # logger should not raise an exception. This rescue prevents unexpected behaviour.
@@ -299,6 +302,7 @@ module Fluent
299
302
  return if skipped_type?(type)
300
303
  args << block.call if block
301
304
  time, msg = event(:debug, args)
305
+ return if time.nil?
302
306
  puts [@color_debug, @formatter.call(type, time, LEVEL_DEBUG, msg), @color_reset].join
303
307
  rescue
304
308
  end
@@ -319,6 +323,7 @@ module Fluent
319
323
  return if skipped_type?(type)
320
324
  args << block.call if block
321
325
  time, msg = event(:info, args)
326
+ return if time.nil?
322
327
  puts [@color_info, @formatter.call(type, time, LEVEL_INFO, msg), @color_reset].join
323
328
  rescue
324
329
  end
@@ -339,6 +344,7 @@ module Fluent
339
344
  return if skipped_type?(type)
340
345
  args << block.call if block
341
346
  time, msg = event(:warn, args)
347
+ return if time.nil?
342
348
  puts [@color_warn, @formatter.call(type, time, LEVEL_WARN, msg), @color_reset].join
343
349
  rescue
344
350
  end
@@ -359,6 +365,7 @@ module Fluent
359
365
  return if skipped_type?(type)
360
366
  args << block.call if block
361
367
  time, msg = event(:error, args)
368
+ return if time.nil?
362
369
  puts [@color_error, @formatter.call(type, time, LEVEL_ERROR, msg), @color_reset].join
363
370
  rescue
364
371
  end
@@ -379,6 +386,7 @@ module Fluent
379
386
  return if skipped_type?(type)
380
387
  args << block.call if block
381
388
  time, msg = event(:fatal, args)
389
+ return if time.nil?
382
390
  puts [@color_fatal, @formatter.call(type, time, LEVEL_FATAL, msg), @color_reset].join
383
391
  rescue
384
392
  end
@@ -412,6 +420,20 @@ module Fluent
412
420
  @out.reset if @out.respond_to?(:reset)
413
421
  end
414
422
 
423
+ CachedLog = Struct.new(:msg, :time)
424
+
425
+ def ignore_repeated_log?(key, time, message)
426
+ cached_log = Thread.current[key]
427
+ return false if cached_log.nil?
428
+ (cached_log.msg == message) && (time - cached_log.time <= @ignore_repeated_log_interval)
429
+ end
430
+
431
+ def suppress_stacktrace?(backtrace)
432
+ cached_log = Thread.current[:last_repeated_stacktrace]
433
+ return false if cached_log.nil?
434
+ cached_log.msg == backtrace
435
+ end
436
+
415
437
  def dump_stacktrace(type, backtrace, level)
416
438
  return if @level > level
417
439
 
@@ -419,13 +441,16 @@ module Fluent
419
441
 
420
442
  if @format == :text
421
443
  line = caller_line(type, time, 5, level)
422
- if @suppress_repeated_stacktrace && (Thread.current[:last_repeated_stacktrace] == backtrace)
444
+ if @ignore_repeated_log_interval && ignore_repeated_log?(:last_repeated_stacktrace, time, backtrace)
445
+ return
446
+ elsif @suppress_repeated_stacktrace && suppress_stacktrace?(backtrace)
423
447
  puts [" ", line, 'suppressed same stacktrace'].join
448
+ Thread.current[:last_repeated_stacktrace] = CachedLog.new(backtrace, time) if @ignore_repeated_log_interval
424
449
  else
425
450
  backtrace.each { |msg|
426
451
  puts [" ", line, msg].join
427
452
  }
428
- Thread.current[:last_repeated_stacktrace] = backtrace if @suppress_repeated_stacktrace
453
+ Thread.current[:last_repeated_stacktrace] = CachedLog.new(backtrace, time) if @suppress_repeated_stacktrace
429
454
  end
430
455
  else
431
456
  r = {
@@ -436,11 +461,14 @@ module Fluent
436
461
  r['worker_id'] = wid
437
462
  end
438
463
 
439
- if @suppress_repeated_stacktrace && (Thread.current[:last_repeated_stacktrace] == backtrace)
464
+ if @ignore_repeated_log_interval && ignore_repeated_log?(:last_repeated_stacktrace, time, backtrace)
465
+ return
466
+ elsif @suppress_repeated_stacktrace && suppress_stacktrace?(backtrace)
440
467
  r['message'] = 'suppressed same stacktrace'
468
+ Thread.current[:last_repeated_stacktrace] = CachedLog.new(backtrace, time) if @ignore_repeated_log_interval
441
469
  else
442
470
  r['message'] = backtrace.join("\n")
443
- Thread.current[:last_repeated_stacktrace] = backtrace if @suppress_repeated_stacktrace
471
+ Thread.current[:last_repeated_stacktrace] = CachedLog.new(backtrace, time) if @suppress_repeated_stacktrace
444
472
  end
445
473
 
446
474
  puts Yajl.dump(r)
@@ -479,6 +507,14 @@ module Fluent
479
507
  end
480
508
  }
481
509
 
510
+ if @ignore_repeated_log_interval
511
+ if ignore_repeated_log?(:last_repeated_log, time, message)
512
+ return nil, nil
513
+ else
514
+ Thread.current[:last_repeated_log] = CachedLog.new(message, time)
515
+ end
516
+ end
517
+
482
518
  if @log_event_enabled && !@threads_exclude_events.include?(Thread.current)
483
519
  record = map.dup
484
520
  record.keys.each {|key|
@@ -530,6 +566,9 @@ module Fluent
530
566
  if logger.instance_variable_defined?(:@suppress_repeated_stacktrace)
531
567
  @suppress_repeated_stacktrace = logger.instance_variable_get(:@suppress_repeated_stacktrace)
532
568
  end
569
+ if logger.instance_variable_defined?(:@ignore_repeated_log_interval)
570
+ @ignore_repeated_log_interval = logger.instance_variable_get(:@ignore_repeated_log_interval)
571
+ end
533
572
 
534
573
  self.format = @logger.format
535
574
  self.time_format = @logger.time_format