fluentd 1.15.3 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/linux-test.yaml +2 -2
  3. data/.github/workflows/macos-test.yaml +2 -2
  4. data/.github/workflows/windows-test.yaml +2 -2
  5. data/CHANGELOG.md +77 -0
  6. data/MAINTAINERS.md +2 -0
  7. data/README.md +0 -1
  8. data/fluentd.gemspec +2 -2
  9. data/lib/fluent/command/fluentd.rb +55 -53
  10. data/lib/fluent/daemon.rb +2 -4
  11. data/lib/fluent/log/console_adapter.rb +66 -0
  12. data/lib/fluent/log.rb +35 -5
  13. data/lib/fluent/plugin/base.rb +5 -7
  14. data/lib/fluent/plugin/buf_file.rb +32 -3
  15. data/lib/fluent/plugin/buf_file_single.rb +32 -3
  16. data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
  17. data/lib/fluent/plugin/buffer.rb +21 -0
  18. data/lib/fluent/plugin/in_tcp.rb +4 -2
  19. data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
  20. data/lib/fluent/plugin/out_forward.rb +2 -2
  21. data/lib/fluent/plugin/out_secondary_file.rb +39 -22
  22. data/lib/fluent/plugin/output.rb +49 -12
  23. data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
  24. data/lib/fluent/supervisor.rb +157 -251
  25. data/lib/fluent/test/driver/base.rb +11 -5
  26. data/lib/fluent/test/driver/filter.rb +4 -0
  27. data/lib/fluent/test/startup_shutdown.rb +6 -8
  28. data/lib/fluent/version.rb +1 -1
  29. data/test/command/test_ctl.rb +1 -1
  30. data/test/command/test_fluentd.rb +137 -6
  31. data/test/command/test_plugin_config_formatter.rb +0 -1
  32. data/test/compat/test_parser.rb +5 -5
  33. data/test/config/test_system_config.rb +0 -8
  34. data/test/log/test_console_adapter.rb +110 -0
  35. data/test/plugin/out_forward/test_ack_handler.rb +39 -0
  36. data/test/plugin/test_base.rb +98 -0
  37. data/test/plugin/test_buf_file.rb +62 -23
  38. data/test/plugin/test_buf_file_single.rb +65 -0
  39. data/test/plugin/test_in_http.rb +2 -3
  40. data/test/plugin/test_in_monitor_agent.rb +2 -3
  41. data/test/plugin/test_in_tcp.rb +15 -0
  42. data/test/plugin/test_out_forward.rb +14 -18
  43. data/test/plugin/test_out_http.rb +1 -0
  44. data/test/plugin/test_output.rb +269 -0
  45. data/test/plugin/test_parser_regexp.rb +1 -6
  46. data/test/plugin_helper/test_http_server_helper.rb +1 -1
  47. data/test/plugin_helper/test_server.rb +10 -5
  48. data/test/test_config.rb +0 -21
  49. data/test/test_formatter.rb +23 -20
  50. data/test/test_log.rb +71 -36
  51. data/test/test_supervisor.rb +277 -282
  52. metadata +12 -19
  53. data/.drone.yml +0 -35
  54. data/.gitlab-ci.yml +0 -103
  55. data/test/test_logger_initializer.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e7d3798a39136da859e23e8bee742d8db252f58ce410cc530710d60dba36c05
4
- data.tar.gz: 82146c03770da1ebbad670fbd356a3020846f27d72e1eaeaed9538fc0b99c9cb
3
+ metadata.gz: 6fc34e74bc59490b0c8a3416ce9028aa92883d875a9d0f20ac4cddfc95bb40d0
4
+ data.tar.gz: 4cdd96916326fceed441e564b82c7024143ee6f179c37d1eb0a3b3746d2d9850
5
5
  SHA512:
6
- metadata.gz: 4b895809bf5e79c5fea8e5a77a485129d8a5912327fb7cbfc176a85e77918068cf24db37cf6e8fba53f24bbdb7e6af7d593a621bcad575faf4299589c8cb662c
7
- data.tar.gz: a0985cfd48858c88f7ec9feb5c87e035361998ae50be98d6f486d9ae897cce350cf1878cd4a2491c40c6faa5a1cb67b3c52484d1100694bb624894635b8bebd6
6
+ metadata.gz: 219d732710b6a7d9f385b4a6a8c254b00f2c6eb98f96fea27e0d1d5947056fa67213a8f5fd5b08361adb92fa7fe2d00e20e4a3bb410523de2538b1a1572214ea
7
+ data.tar.gz: 4350fa09941c69bff107d383fd6c5b4a084f579843b2d65bd979da612418e0e9bc2185dd6dca96e0d77cc03a1d3b79bf0e9856d9f4abc9d7336af4b50b95a41b
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby-version: ['3.1', '3.0', '2.7']
16
+ ruby-version: ['3.2', '3.1', '3.0', '2.7']
17
17
  os: [ubuntu-latest]
18
18
  experimental: [false]
19
19
  include:
@@ -23,7 +23,7 @@ jobs:
23
23
 
24
24
  name: Unit testing with Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
25
25
  steps:
26
- - uses: actions/checkout@v2
26
+ - uses: actions/checkout@v3
27
27
  - name: Set up Ruby
28
28
  uses: ruby/setup-ruby@v1
29
29
  with:
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby-version: ['3.1', '3.0', '2.7']
16
+ ruby-version: ['3.2', '3.1', '3.0', '2.7']
17
17
  os: [macos-latest]
18
18
  experimental: [true]
19
19
  include:
@@ -23,7 +23,7 @@ jobs:
23
23
 
24
24
  name: Unit testing with Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
25
25
  steps:
26
- - uses: actions/checkout@v2
26
+ - uses: actions/checkout@v3
27
27
  - name: Set up Ruby
28
28
  uses: ruby/setup-ruby@v1
29
29
  with:
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby-version: ['3.1', '2.7']
16
+ ruby-version: ['3.2', '3.1', '2.7']
17
17
  os:
18
18
  - windows-latest
19
19
  experimental: [false]
@@ -35,7 +35,7 @@ jobs:
35
35
 
36
36
  name: Unit testing with Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
37
37
  steps:
38
- - uses: actions/checkout@v2
38
+ - uses: actions/checkout@v3
39
39
  - name: Set up Ruby
40
40
  uses: ruby/setup-ruby@v1
41
41
  with:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,80 @@
1
+ # v1.16
2
+
3
+ ## Release v1.16.0 - 2023/03/29
4
+
5
+ ### Enhancement
6
+
7
+ * in_tcp: Add `send_keepalive_packet` option
8
+ https://github.com/fluent/fluentd/pull/3961
9
+ * buffer: backup broken file chunk
10
+ https://github.com/fluent/fluentd/pull/4025
11
+ * Add warning messages for restoring buffer with `flush_at_shutdown true`
12
+ https://github.com/fluent/fluentd/pull/4027
13
+ * Add logs for time period of restored buffer possibly broken
14
+ https://github.com/fluent/fluentd/pull/4028
15
+
16
+ ### Bug Fix
17
+
18
+ * http_server_helper: Fix format of log messages originating from Async gem
19
+ https://github.com/fluent/fluentd/pull/3987
20
+ * Change to not generate a sigdump file after receiving a `SIGTERM` signal on
21
+ non-Windows
22
+ https://github.com/fluent/fluentd/pull/4034
23
+ https://github.com/fluent/fluentd/pull/4043
24
+ * out_forward: fix error of ack handling conflict on stopping with
25
+ `require_ack_response` enabled
26
+ https://github.com/fluent/fluentd/pull/4030
27
+ * Fix problem that some `system` configs are not reflected
28
+ https://github.com/fluent/fluentd/pull/4064
29
+ https://github.com/fluent/fluentd/pull/4065
30
+ https://github.com/fluent/fluentd/pull/4086
31
+ https://github.com/fluent/fluentd/pull/4090
32
+ https://github.com/fluent/fluentd/pull/4096
33
+ * Fix bug that the logger outputs some initial log messages without applying
34
+ some settings such as `format`
35
+ https://github.com/fluent/fluentd/pull/4091
36
+ * Windows: Fix a bug that the wrong log file is reopened with log rotate setting
37
+ when flushing or graceful reloading
38
+ https://github.com/fluent/fluentd/pull/4054
39
+ * Fix race condition of out_secondary_file
40
+ https://github.com/fluent/fluentd/pull/4081
41
+ * Suppress warning using different secondary for out_secondary_file
42
+ https://github.com/fluent/fluentd/pull/4087
43
+ * Fix value of `system_config.workers` at `run_configure`.
44
+ Change argument type of `Fluent::Plugin::Base::configure()` to
45
+ `Fluent::Config::Element` only.
46
+ https://github.com/fluent/fluentd/pull/4066
47
+ * Fix bug that Fluentd sometimes tries to use an unavailable port and fails to
48
+ start on Windows
49
+ https://github.com/fluent/fluentd/pull/4092
50
+
51
+ ### Misc
52
+
53
+ * Add method for testing `filtered_with_time`
54
+ https://github.com/fluent/fluentd/pull/3899
55
+ * Replace `$$` with `Process.pid`
56
+ https://github.com/fluent/fluentd/pull/4040
57
+ * Relax required webric gem version
58
+ https://github.com/fluent/fluentd/pull/4061
59
+ * CI fixes to support Ruby 3.2
60
+ https://github.com/fluent/fluentd/pull/3968
61
+ https://github.com/fluent/fluentd/pull/3996
62
+ https://github.com/fluent/fluentd/pull/3997
63
+ * Other CI fixes
64
+ https://github.com/fluent/fluentd/pull/3969
65
+ https://github.com/fluent/fluentd/pull/3990
66
+ https://github.com/fluent/fluentd/pull/4013
67
+ https://github.com/fluent/fluentd/pull/4033
68
+ https://github.com/fluent/fluentd/pull/4044
69
+ https://github.com/fluent/fluentd/pull/4050
70
+ https://github.com/fluent/fluentd/pull/4062
71
+ https://github.com/fluent/fluentd/pull/4074
72
+ https://github.com/fluent/fluentd/pull/4082
73
+ https://github.com/fluent/fluentd/pull/4085
74
+ * Update MAINTAINERS.md
75
+ https://github.com/fluent/fluentd/pull/4026
76
+ https://github.com/fluent/fluentd/pull/4069
77
+
1
78
  # v1.15
2
79
 
3
80
  ## Release v1.15.3 - 2022/11/02
data/MAINTAINERS.md CHANGED
@@ -5,7 +5,9 @@
5
5
  - [Hiroshi Hatake](https://github.com/cosmo0920), [Calyptia](https://calyptia.com/)
6
6
  - [Masahiro Nakagawa](https://github.com/repeatedly), [Treasure Data](https://www.treasuredata.com/)
7
7
  - [Satoshi Tagomori](https://github.com/tagomoris), [Treasure Data](https://www.treasuredata.com/)
8
+ - [Toru Takahashi](https://github.com/toru-takahashi), [Treasure Data](https://www.treasuredata.com/)
8
9
  - [Eduardo Silva](https://github.com/edsiper), [Calyptia](https://calyptia/)
9
10
  - [Fujimoto Seiji](https://github.com/fujimots), [ClearCode](https://www.clear-code.com/)
10
11
  - [Takuro Ashie](https://github.com/ashie), [ClearCode](https://www.clear-code.com/)
11
12
  - [Kentaro Hayashi](https://github.com/kenhys), [ClearCode](https://www.clear-code.com/)
13
+ - [Daijiro Fukuda](https://github.com/daipom), [ClearCode](https://www.clear-code.com/)
data/README.md CHANGED
@@ -4,7 +4,6 @@ Fluentd: Open-Source Log Collector
4
4
  [![Testing on Ubuntu](https://github.com/fluent/fluentd/actions/workflows/linux-test.yaml/badge.svg?branch=master)](https://github.com/fluent/fluentd/actions/workflows/linux-test.yaml)
5
5
  [![Testing on Windows](https://github.com/fluent/fluentd/actions/workflows/windows-test.yaml/badge.svg?branch=master)](https://github.com/fluent/fluentd/actions/workflows/windows-test.yaml)
6
6
  [![Testing on macOS](https://github.com/fluent/fluentd/actions/workflows/macos-test.yaml/badge.svg?branch=master)](https://github.com/fluent/fluentd/actions/workflows/macos-test.yaml)
7
- [![Testing on Arm64](https://cloud.drone.io/api/badges/fluent/fluentd/status.svg?branch=master)](https://cloud.drone.io/fluent/fluentd)
8
7
  [![Code Climate](https://codeclimate.com/github/fluent/fluentd/badges/gpa.svg)](https://codeclimate.com/github/fluent/fluentd)
9
8
  [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1189/badge)](https://bestpractices.coreinfrastructure.org/projects/1189)
10
9
 
data/fluentd.gemspec CHANGED
@@ -22,13 +22,13 @@ Gem::Specification.new do |gem|
22
22
  gem.add_runtime_dependency("msgpack", [">= 1.3.1", "< 2.0.0"])
23
23
  gem.add_runtime_dependency("yajl-ruby", ["~> 1.0"])
24
24
  gem.add_runtime_dependency("cool.io", [">= 1.4.5", "< 2.0.0"])
25
- gem.add_runtime_dependency("serverengine", [">= 2.3.0", "< 3.0.0"])
25
+ gem.add_runtime_dependency("serverengine", [">= 2.3.2", "< 3.0.0"])
26
26
  gem.add_runtime_dependency("http_parser.rb", [">= 0.5.1", "< 0.9.0"])
27
27
  gem.add_runtime_dependency("sigdump", ["~> 0.2.2"])
28
28
  gem.add_runtime_dependency("tzinfo", [">= 1.0", "< 3.0"])
29
29
  gem.add_runtime_dependency("tzinfo-data", ["~> 1.0"])
30
30
  gem.add_runtime_dependency("strptime", [">= 0.2.4", "< 1.0.0"])
31
- gem.add_runtime_dependency("webrick", [">= 1.4.2", "< 1.8.0"])
31
+ gem.add_runtime_dependency("webrick", ["~> 1.4"])
32
32
 
33
33
  # build gem for a certain platform. see also Rakefile
34
34
  fake_platform = ENV['GEM_BUILD_FAKE_PLATFORM'].to_s
@@ -26,26 +26,27 @@ $fluentdargv = Marshal.load(Marshal.dump(ARGV))
26
26
  op = OptionParser.new
27
27
  op.version = Fluent::VERSION
28
28
 
29
- opts = Fluent::Supervisor.default_options
29
+ default_opts = Fluent::Supervisor.default_options
30
+ cmd_opts = {}
30
31
 
31
32
  op.on('-s', "--setup [DIR=#{File.dirname(Fluent::DEFAULT_CONFIG_PATH)}]", "install sample configuration file to the directory") {|s|
32
- opts[:setup_path] = s || File.dirname(Fluent::DEFAULT_CONFIG_PATH)
33
+ cmd_opts[:setup_path] = s || File.dirname(Fluent::DEFAULT_CONFIG_PATH)
33
34
  }
34
35
 
35
36
  op.on('-c', '--config PATH', "config file path (default: #{Fluent::DEFAULT_CONFIG_PATH})") {|s|
36
- opts[:config_path] = s
37
+ cmd_opts[:config_path] = s
37
38
  }
38
39
 
39
40
  op.on('--dry-run', "Check fluentd setup is correct or not", TrueClass) {|b|
40
- opts[:dry_run] = b
41
+ cmd_opts[:dry_run] = b
41
42
  }
42
43
 
43
44
  op.on('--show-plugin-config=PLUGIN', "[DEPRECATED] Show PLUGIN configuration and exit(ex: input:dummy)") {|plugin|
44
- opts[:show_plugin_config] = plugin
45
+ cmd_opts[:show_plugin_config] = plugin
45
46
  }
46
47
 
47
48
  op.on('-p', '--plugin DIR', "add plugin directory") {|s|
48
- opts[:plugin_dirs] << s
49
+ (cmd_opts[:plugin_dirs] ||= []) << s
49
50
  }
50
51
 
51
52
  op.on('-I PATH', "add library path") {|s|
@@ -53,48 +54,48 @@ op.on('-I PATH', "add library path") {|s|
53
54
  }
54
55
 
55
56
  op.on('-r NAME', "load library") {|s|
56
- opts[:libs] << s
57
+ (cmd_opts[:libs] ||= []) << s
57
58
  }
58
59
 
59
60
  op.on('-d', '--daemon PIDFILE', "daemonize fluent process") {|s|
60
- opts[:daemonize] = s
61
+ cmd_opts[:daemonize] = s
61
62
  }
62
63
 
63
64
  op.on('--under-supervisor', "run fluent worker under supervisor (this option is NOT for users)") {
64
- opts[:supervise] = false
65
+ cmd_opts[:supervise] = false
65
66
  }
66
67
 
67
68
  op.on('--no-supervisor', "run fluent worker without supervisor") {
68
- opts[:supervise] = false
69
- opts[:standalone_worker] = true
69
+ cmd_opts[:supervise] = false
70
+ cmd_opts[:standalone_worker] = true
70
71
  }
71
72
 
72
73
  op.on('--workers NUM', "specify the number of workers under supervisor") { |i|
73
- opts[:workers] = i.to_i
74
+ cmd_opts[:workers] = i.to_i
74
75
  }
75
76
 
76
77
  op.on('--user USER', "change user") {|s|
77
- opts[:chuser] = s
78
+ cmd_opts[:chuser] = s
78
79
  }
79
80
 
80
81
  op.on('--group GROUP', "change group") {|s|
81
- opts[:chgroup] = s
82
+ cmd_opts[:chgroup] = s
82
83
  }
83
84
 
84
85
  op.on('--umask UMASK', "change umask") {|s|
85
- opts[:chumask] = s
86
+ cmd_opts[:chumask] = s
86
87
  }
87
88
 
88
89
  op.on('-o', '--log PATH', "log file path") {|s|
89
- opts[:log_path] = s
90
+ cmd_opts[:log_path] = s
90
91
  }
91
92
 
92
93
  op.on('--log-rotate-age AGE', 'generations to keep rotated log files') {|age|
93
94
  if Fluent::Log::LOG_ROTATE_AGE.include?(age)
94
- opts[:log_rotate_age] = age
95
+ cmd_opts[:log_rotate_age] = age
95
96
  else
96
97
  begin
97
- opts[:log_rotate_age] = Integer(age)
98
+ cmd_opts[:log_rotate_age] = Integer(age)
98
99
  rescue TypeError, ArgumentError
99
100
  usage "log-rotate-age should be #{ROTATE_AGE.join(', ')} or a number"
100
101
  end
@@ -102,129 +103,129 @@ op.on('--log-rotate-age AGE', 'generations to keep rotated log files') {|age|
102
103
  }
103
104
 
104
105
  op.on('--log-rotate-size BYTES', 'sets the byte size to rotate log files') {|s|
105
- opts[:log_rotate_size] = s.to_i
106
+ cmd_opts[:log_rotate_size] = s.to_i
106
107
  }
107
108
 
108
109
  op.on('--log-event-verbose', 'enable log events during process startup/shutdown') {|b|
109
- opts[:log_event_verbose] = b
110
+ cmd_opts[:log_event_verbose] = b
110
111
  }
111
112
 
112
113
  op.on('-i', '--inline-config CONFIG_STRING', "inline config which is appended to the config file on-the-fly") {|s|
113
- opts[:inline_config] = s
114
+ cmd_opts[:inline_config] = s
114
115
  }
115
116
 
116
117
  op.on('--emit-error-log-interval SECONDS', "suppress interval seconds of emit error logs") {|s|
117
- opts[:suppress_interval] = s.to_i
118
+ cmd_opts[:suppress_interval] = s.to_i
118
119
  }
119
120
 
120
121
  op.on('--suppress-repeated-stacktrace [VALUE]', "suppress repeated stacktrace", TrueClass) {|b|
121
122
  b = true if b.nil?
122
- opts[:suppress_repeated_stacktrace] = b
123
+ cmd_opts[:suppress_repeated_stacktrace] = b
123
124
  }
124
125
 
125
126
  op.on('--without-source', "invoke a fluentd without input plugins", TrueClass) {|b|
126
- opts[:without_source] = b
127
+ cmd_opts[:without_source] = b
127
128
  }
128
129
 
129
130
  op.on('--config-file-type VALU', 'guessing file type of fluentd configuration. yaml/yml or guess') { |s|
130
131
  if (s == 'yaml') || (s == 'yml')
131
- opts[:config_file_type] = s.to_sym
132
+ cmd_opts[:config_file_type] = s.to_sym
132
133
  elsif (s == 'guess')
133
- opts[:config_file_type] = s.to_sym
134
+ cmd_opts[:config_file_type] = s.to_sym
134
135
  else
135
136
  usage '--config-file-type accepts yaml/yml or guess'
136
137
  end
137
138
  }
138
139
 
139
140
  op.on('--use-v1-config', "Use v1 configuration format (default)", TrueClass) {|b|
140
- opts[:use_v1_config] = b
141
+ cmd_opts[:use_v1_config] = b
141
142
  }
142
143
 
143
144
  op.on('--use-v0-config', "Use v0 configuration format", TrueClass) {|b|
144
- opts[:use_v1_config] = !b
145
+ cmd_opts[:use_v1_config] = !b
145
146
  }
146
147
 
147
148
  op.on('--strict-config-value', "Parse config values strictly", TrueClass) {|b|
148
- opts[:strict_config_value] = b
149
+ cmd_opts[:strict_config_value] = b
149
150
  }
150
151
 
151
152
  op.on('--enable-input-metrics', "Enable input plugin metrics on fluentd", TrueClass) {|b|
152
- opts[:enable_input_metrics] = b
153
+ cmd_opts[:enable_input_metrics] = b
153
154
  }
154
155
 
155
156
  op.on('--enable-size-metrics', "Enable plugin record size metrics on fluentd", TrueClass) {|b|
156
- opts[:enable_size_metrics] = b
157
+ cmd_opts[:enable_size_metrics] = b
157
158
  }
158
159
 
159
160
  op.on('-v', '--verbose', "increase verbose level (-v: debug, -vv: trace)", TrueClass) {|b|
160
- if b
161
- opts[:log_level] = [opts[:log_level] - 1, Fluent::Log::LEVEL_TRACE].max
162
- end
161
+ return unless b
162
+ cur_level = cmd_opts.fetch(:log_level, default_opts[:log_level])
163
+ cmd_opts[:log_level] = [cur_level - 1, Fluent::Log::LEVEL_TRACE].max
163
164
  }
164
165
 
165
166
  op.on('-q', '--quiet', "decrease verbose level (-q: warn, -qq: error)", TrueClass) {|b|
166
- if b
167
- opts[:log_level] = [opts[:log_level] + 1, Fluent::Log::LEVEL_ERROR].min
168
- end
167
+ return unless b
168
+ cur_level = cmd_opts.fetch(:log_level, default_opts[:log_level])
169
+ cmd_opts[:log_level] = [cur_level + 1, Fluent::Log::LEVEL_ERROR].min
169
170
  }
170
171
 
171
172
  op.on('--suppress-config-dump', "suppress config dumping when fluentd starts", TrueClass) {|b|
172
- opts[:suppress_config_dump] = b
173
+ cmd_opts[:suppress_config_dump] = b
173
174
  }
174
175
 
175
176
  op.on('-g', '--gemfile GEMFILE', "Gemfile path") {|s|
176
- opts[:gemfile] = s
177
+ cmd_opts[:gemfile] = s
177
178
  }
178
179
 
179
180
  op.on('-G', '--gem-path GEM_INSTALL_PATH', "Gemfile install path (default: $(dirname $gemfile)/vendor/bundle)") {|s|
180
- opts[:gem_install_path] = s
181
+ cmd_opts[:gem_install_path] = s
181
182
  }
182
183
 
183
184
  op.on('--conf-encoding ENCODING', "specify configuration file encoding") { |s|
184
- opts[:conf_encoding] = s
185
+ cmd_opts[:conf_encoding] = s
185
186
  }
186
187
 
187
188
  op.on('--disable-shared-socket', "Don't open shared socket for multiple workers") { |b|
188
- opts[:disable_shared_socket] = b
189
+ cmd_opts[:disable_shared_socket] = b
189
190
  }
190
191
 
191
192
  if Fluent.windows?
192
- opts.merge!(
193
+ cmd_opts.merge!(
193
194
  :winsvc_name => 'fluentdwinsvc',
194
195
  :winsvc_display_name => 'Fluentd Windows Service',
195
196
  :winsvc_desc => 'Fluentd is an event collector system.',
196
197
  )
197
198
 
198
199
  op.on('-x', '--signame INTSIGNAME', "an object name which is used for Windows Service signal (Windows only)") {|s|
199
- opts[:signame] = s
200
+ cmd_opts[:signame] = s
200
201
  }
201
202
 
202
203
  op.on('--reg-winsvc MODE', "install/uninstall as Windows Service. (i: install, u: uninstall) (Windows only)") {|s|
203
- opts[:regwinsvc] = s
204
+ cmd_opts[:regwinsvc] = s
204
205
  }
205
206
 
206
207
  op.on('--[no-]reg-winsvc-auto-start', "Automatically start the Windows Service at boot. (only effective with '--reg-winsvc i') (Windows only)") {|s|
207
- opts[:regwinsvcautostart] = s
208
+ cmd_opts[:regwinsvcautostart] = s
208
209
  }
209
210
 
210
211
  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|
211
- opts[:regwinsvcdelaystart] = s
212
+ cmd_opts[:regwinsvcdelaystart] = s
212
213
  }
213
214
 
214
215
  op.on('--reg-winsvc-fluentdopt OPTION', "specify fluentd option parameters for Windows Service. (Windows only)") {|s|
215
- opts[:fluentdopt] = s
216
+ cmd_opts[:fluentdopt] = s
216
217
  }
217
218
 
218
219
  op.on('--winsvc-name NAME', "The Windows Service name to run as (Windows only)") {|s|
219
- opts[:winsvc_name] = s
220
+ cmd_opts[:winsvc_name] = s
220
221
  }
221
222
 
222
223
  op.on('--winsvc-display-name DISPLAY_NAME', "The Windows Service display name (Windows only)") {|s|
223
- opts[:winsvc_display_name] = s
224
+ cmd_opts[:winsvc_display_name] = s
224
225
  }
225
226
 
226
227
  op.on('--winsvc-desc DESC', "The Windows Service description (Windows only)") {|s|
227
- opts[:winsvc_desc] = s
228
+ cmd_opts[:winsvc_desc] = s
228
229
  }
229
230
  end
230
231
 
@@ -247,6 +248,7 @@ rescue
247
248
  usage $!.to_s
248
249
  end
249
250
 
251
+ opts = default_opts.merge(cmd_opts)
250
252
 
251
253
  ##
252
254
  ## Bundler injection
@@ -345,7 +347,7 @@ end
345
347
  exit 0 if early_exit
346
348
 
347
349
  if opts[:supervise]
348
- supervisor = Fluent::Supervisor.new(opts)
350
+ supervisor = Fluent::Supervisor.new(cmd_opts)
349
351
  supervisor.configure(supervisor: true)
350
352
  supervisor.run_supervisor(dry_run: opts[:dry_run])
351
353
  else
@@ -353,7 +355,7 @@ else
353
355
  puts "Error: multi workers is not supported with --no-supervisor"
354
356
  exit 2
355
357
  end
356
- worker = Fluent::Supervisor.new(opts)
358
+ worker = Fluent::Supervisor.new(cmd_opts)
357
359
  worker.configure
358
360
 
359
361
  if opts[:daemonize] && opts[:standalone_worker]
data/lib/fluent/daemon.rb CHANGED
@@ -9,7 +9,5 @@ require 'fluent/supervisor'
9
9
 
10
10
  server_module = Fluent.const_get(ARGV[0])
11
11
  worker_module = Fluent.const_get(ARGV[1])
12
- # it doesn't call ARGV in block because when reloading config, params will be initialized and then it can't use previous config.
13
- config_path = ARGV[2]
14
- params = JSON.parse(ARGV[3])
15
- ServerEngine::Daemon.run_server(server_module, worker_module) { Fluent::Supervisor.load_config(config_path, params) }
12
+ params = JSON.parse(ARGV[2])
13
+ ServerEngine::Daemon.run_server(server_module, worker_module) { Fluent::Supervisor.serverengine_config(params) }
@@ -0,0 +1,66 @@
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 'console/terminal/logger'
18
+
19
+ module Fluent
20
+ class Log
21
+ # Async gem which is used by http_server helper switched logger mechanism to
22
+ # Console gem which isn't complatible with Ruby's standard Logger (since
23
+ # v1.17). This class adapts it to Fluentd's logger mechanism.
24
+ class ConsoleAdapter < Console::Terminal::Logger
25
+ def self.wrap(logger)
26
+ _, level = Console::Logger::LEVELS.find { |key, value|
27
+ if logger.level <= 0
28
+ key == :debug
29
+ else
30
+ value == logger.level - 1
31
+ end
32
+ }
33
+ Console::Logger.new(ConsoleAdapter.new(logger), level: level)
34
+ end
35
+
36
+ def initialize(logger)
37
+ @logger = logger
38
+ # When `verbose` is `true`, following items will be added as a prefix or
39
+ # suffix of the subject:
40
+ # * Severity
41
+ # * Object ID
42
+ # * PID
43
+ # * Time
44
+ # Severity and Time are added by Fluentd::Log too so they are redundant.
45
+ # PID is the worker's PID so it's also redundant.
46
+ # Object ID will be too verbose in usual cases.
47
+ # So set it as `false` here to suppress redundant items.
48
+ super(StringIO.new, verbose: false)
49
+ end
50
+
51
+ def call(subject = nil, *arguments, name: nil, severity: 'info', **options, &block)
52
+ if LEVEL_TEXT.include?(severity.to_s)
53
+ level = severity
54
+ else
55
+ @logger.warn("Unknown severity: #{severity}")
56
+ level = 'warn'
57
+ end
58
+
59
+ @io.seek(0)
60
+ @io.truncate(0)
61
+ super
62
+ @logger.send(level, @io.string.chomp)
63
+ end
64
+ end
65
+ end
66
+ end
data/lib/fluent/log.rb CHANGED
@@ -67,8 +67,29 @@ module Fluent
67
67
  LEVEL_TEXT.map{|t| "#{LOG_EVENT_TAG_PREFIX}.#{t}" }
68
68
  end
69
69
 
70
+ # Create a unique path for each process.
71
+ #
72
+ # >>> per_process_path("C:/tmp/test.log", :worker, 1)
73
+ # C:/tmp/test-1.log
74
+ # >>> per_process_path("C:/tmp/test.log", :supervisor, 0)
75
+ # C:/tmp/test-supervisor-0.log
76
+ def self.per_process_path(path, process_type, worker_id)
77
+ path = Pathname(path)
78
+ ext = path.extname
79
+
80
+ if process_type == :supervisor
81
+ suffix = "-#{process_type}-0#{ext}" # "-0" for backword compatibility.
82
+ else
83
+ suffix = "-#{worker_id}#{ext}"
84
+ end
85
+ return path.sub_ext(suffix).to_s
86
+ end
87
+
70
88
  def initialize(logger, opts={})
71
- # overwrites logger.level= so that config reloading resets level of Fluentd::Log
89
+ # When ServerEngine changes the logger.level, the Fluentd logger level should also change.
90
+ # So overwrites logger.level= below.
91
+ # However, currently Fluentd doesn't use the ServerEngine's reloading feature,
92
+ # so maybe we don't need this overwriting anymore.
72
93
  orig_logger_level_setter = logger.class.public_instance_method(:level=).bind(logger)
73
94
  me = self
74
95
  # The original ruby logger sets the number as each log level like below.
@@ -92,6 +113,7 @@ module Fluent
92
113
  # So if serverengine's logger level is changed, fluentd's log level will be changed to that + 1.
93
114
  logger.define_singleton_method(:level=) {|level| orig_logger_level_setter.call(level); me.level = self.level + 1 }
94
115
 
116
+ @path = opts[:path]
95
117
  @logger = logger
96
118
  @out = logger.instance_variable_get(:@logdev)
97
119
  @level = logger.level + 1
@@ -102,7 +124,8 @@ module Fluent
102
124
  @time_format = nil
103
125
  @formatter = nil
104
126
 
105
- self.format = :text
127
+ self.format = opts.fetch(:format, :text)
128
+ self.time_format = opts[:time_format] if opts.key?(:time_format)
106
129
  enable_color out.tty?
107
130
  # TODO: This variable name is unclear so we should change to better name.
108
131
  @threads_exclude_events = []
@@ -154,8 +177,12 @@ module Fluent
154
177
 
155
178
  attr_reader :format
156
179
  attr_reader :time_format
157
- attr_accessor :log_event_enabled, :ignore_repeated_log_interval, :ignore_same_log_interval
180
+ attr_accessor :log_event_enabled, :ignore_repeated_log_interval, :ignore_same_log_interval, :suppress_repeated_stacktrace
158
181
  attr_accessor :out
182
+ # Strictly speaking, we should also change @logger.level when the setter of @level is called.
183
+ # Currently, we don't need to do it, since Fluentd::Log doesn't use ServerEngine::DaemonLogger.level.
184
+ # Since We overwrites logger.level= so that @logger.level is applied to @level,
185
+ # we need to find a good way to do this, otherwise we will end up in an endless loop.
159
186
  attr_accessor :level
160
187
  attr_accessor :optional_header, :optional_attrs
161
188
 
@@ -202,9 +229,12 @@ module Fluent
202
229
  @time_formatter = Strftime.new(@time_format) rescue nil
203
230
  end
204
231
 
232
+ def stdout?
233
+ @out == $stdout
234
+ end
235
+
205
236
  def reopen!
206
- # do nothing in @logger.reopen! because it's already reopened in Supervisor.load_config
207
- @logger.reopen! if @logger
237
+ @out.reopen(@path, "a") if @path && @path != "-"
208
238
  nil
209
239
  end
210
240
 
@@ -53,14 +53,12 @@ module Fluent
53
53
  end
54
54
 
55
55
  def configure(conf)
56
- if Fluent::Engine.supervisor_mode || (conf.respond_to?(:for_this_worker?) && conf.for_this_worker?)
57
- workers = if conf.target_worker_ids && !conf.target_worker_ids.empty?
58
- conf.target_worker_ids.size
59
- else
60
- 1
61
- end
62
- system_config_override(workers: workers)
56
+ raise ArgumentError, "BUG: type of conf must be Fluent::Config::Element, but #{conf.class} is passed." unless conf.is_a?(Fluent::Config::Element)
57
+
58
+ if conf.for_this_worker? || (Fluent::Engine.supervisor_mode && !conf.for_every_workers?)
59
+ system_config_override(workers: conf.target_worker_ids.size)
63
60
  end
61
+
64
62
  super(conf, system_config.strict_config_value)
65
63
  @_state ||= State.new(false, false, false, false, false, false, false, false, false)
66
64
  @_state.configure = true