fluentd 0.14.4-x86-mingw32

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 (328) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +6 -0
  3. data/.gitignore +26 -0
  4. data/.travis.yml +45 -0
  5. data/AUTHORS +2 -0
  6. data/CONTRIBUTING.md +35 -0
  7. data/COPYING +14 -0
  8. data/ChangeLog +276 -0
  9. data/Gemfile +9 -0
  10. data/README.md +51 -0
  11. data/Rakefile +53 -0
  12. data/Vagrantfile +17 -0
  13. data/appveyor.yml +41 -0
  14. data/bin/fluent-debug +5 -0
  15. data/example/copy_roundrobin.conf +39 -0
  16. data/example/filter_stdout.conf +22 -0
  17. data/example/in_forward.conf +11 -0
  18. data/example/in_http.conf +14 -0
  19. data/example/in_out_forward.conf +17 -0
  20. data/example/in_syslog.conf +15 -0
  21. data/example/in_tail.conf +14 -0
  22. data/example/in_tcp.conf +13 -0
  23. data/example/in_udp.conf +13 -0
  24. data/example/multi_filters.conf +61 -0
  25. data/example/out_buffered_null.conf +32 -0
  26. data/example/out_copy.conf +20 -0
  27. data/example/out_file.conf +13 -0
  28. data/example/out_forward.conf +35 -0
  29. data/example/out_forward_buf_file.conf +23 -0
  30. data/example/v0_12_filter.conf +78 -0
  31. data/example/v1_literal_example.conf +36 -0
  32. data/fluent.conf +139 -0
  33. data/fluentd.gemspec +51 -0
  34. data/lib/fluent/agent.rb +194 -0
  35. data/lib/fluent/command/bundler_injection.rb +45 -0
  36. data/lib/fluent/command/cat.rb +319 -0
  37. data/lib/fluent/command/debug.rb +102 -0
  38. data/lib/fluent/command/fluentd.rb +273 -0
  39. data/lib/fluent/compat/call_super_mixin.rb +67 -0
  40. data/lib/fluent/compat/exec_util.rb +129 -0
  41. data/lib/fluent/compat/file_util.rb +54 -0
  42. data/lib/fluent/compat/filter.rb +68 -0
  43. data/lib/fluent/compat/formatter.rb +111 -0
  44. data/lib/fluent/compat/formatter_utils.rb +85 -0
  45. data/lib/fluent/compat/handle_tag_and_time_mixin.rb +62 -0
  46. data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
  47. data/lib/fluent/compat/input.rb +49 -0
  48. data/lib/fluent/compat/output.rb +677 -0
  49. data/lib/fluent/compat/output_chain.rb +60 -0
  50. data/lib/fluent/compat/parser.rb +180 -0
  51. data/lib/fluent/compat/parser_utils.rb +40 -0
  52. data/lib/fluent/compat/propagate_default.rb +62 -0
  53. data/lib/fluent/compat/record_filter_mixin.rb +34 -0
  54. data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
  55. data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
  56. data/lib/fluent/compat/socket_util.rb +165 -0
  57. data/lib/fluent/compat/string_util.rb +34 -0
  58. data/lib/fluent/compat/structured_format_mixin.rb +26 -0
  59. data/lib/fluent/compat/type_converter.rb +90 -0
  60. data/lib/fluent/config.rb +56 -0
  61. data/lib/fluent/config/basic_parser.rb +123 -0
  62. data/lib/fluent/config/configure_proxy.rb +366 -0
  63. data/lib/fluent/config/dsl.rb +149 -0
  64. data/lib/fluent/config/element.rb +218 -0
  65. data/lib/fluent/config/error.rb +26 -0
  66. data/lib/fluent/config/literal_parser.rb +251 -0
  67. data/lib/fluent/config/parser.rb +107 -0
  68. data/lib/fluent/config/section.rb +212 -0
  69. data/lib/fluent/config/types.rb +136 -0
  70. data/lib/fluent/config/v1_parser.rb +190 -0
  71. data/lib/fluent/configurable.rb +176 -0
  72. data/lib/fluent/daemon.rb +15 -0
  73. data/lib/fluent/engine.rb +220 -0
  74. data/lib/fluent/env.rb +27 -0
  75. data/lib/fluent/event.rb +287 -0
  76. data/lib/fluent/event_router.rb +259 -0
  77. data/lib/fluent/filter.rb +21 -0
  78. data/lib/fluent/formatter.rb +23 -0
  79. data/lib/fluent/input.rb +21 -0
  80. data/lib/fluent/label.rb +38 -0
  81. data/lib/fluent/load.rb +36 -0
  82. data/lib/fluent/log.rb +445 -0
  83. data/lib/fluent/match.rb +141 -0
  84. data/lib/fluent/mixin.rb +31 -0
  85. data/lib/fluent/msgpack_factory.rb +62 -0
  86. data/lib/fluent/output.rb +26 -0
  87. data/lib/fluent/output_chain.rb +23 -0
  88. data/lib/fluent/parser.rb +23 -0
  89. data/lib/fluent/plugin.rb +161 -0
  90. data/lib/fluent/plugin/bare_output.rb +63 -0
  91. data/lib/fluent/plugin/base.rb +130 -0
  92. data/lib/fluent/plugin/buf_file.rb +154 -0
  93. data/lib/fluent/plugin/buf_memory.rb +34 -0
  94. data/lib/fluent/plugin/buffer.rb +603 -0
  95. data/lib/fluent/plugin/buffer/chunk.rb +160 -0
  96. data/lib/fluent/plugin/buffer/file_chunk.rb +323 -0
  97. data/lib/fluent/plugin/buffer/memory_chunk.rb +90 -0
  98. data/lib/fluent/plugin/exec_util.rb +22 -0
  99. data/lib/fluent/plugin/file_util.rb +22 -0
  100. data/lib/fluent/plugin/file_wrapper.rb +120 -0
  101. data/lib/fluent/plugin/filter.rb +93 -0
  102. data/lib/fluent/plugin/filter_grep.rb +75 -0
  103. data/lib/fluent/plugin/filter_record_transformer.rb +342 -0
  104. data/lib/fluent/plugin/filter_stdout.rb +53 -0
  105. data/lib/fluent/plugin/formatter.rb +45 -0
  106. data/lib/fluent/plugin/formatter_csv.rb +47 -0
  107. data/lib/fluent/plugin/formatter_hash.rb +29 -0
  108. data/lib/fluent/plugin/formatter_json.rb +44 -0
  109. data/lib/fluent/plugin/formatter_ltsv.rb +41 -0
  110. data/lib/fluent/plugin/formatter_msgpack.rb +29 -0
  111. data/lib/fluent/plugin/formatter_out_file.rb +78 -0
  112. data/lib/fluent/plugin/formatter_single_value.rb +34 -0
  113. data/lib/fluent/plugin/formatter_stdout.rb +74 -0
  114. data/lib/fluent/plugin/in_debug_agent.rb +64 -0
  115. data/lib/fluent/plugin/in_dummy.rb +135 -0
  116. data/lib/fluent/plugin/in_exec.rb +149 -0
  117. data/lib/fluent/plugin/in_forward.rb +366 -0
  118. data/lib/fluent/plugin/in_gc_stat.rb +52 -0
  119. data/lib/fluent/plugin/in_http.rb +422 -0
  120. data/lib/fluent/plugin/in_monitor_agent.rb +401 -0
  121. data/lib/fluent/plugin/in_object_space.rb +90 -0
  122. data/lib/fluent/plugin/in_syslog.rb +204 -0
  123. data/lib/fluent/plugin/in_tail.rb +838 -0
  124. data/lib/fluent/plugin/in_tcp.rb +41 -0
  125. data/lib/fluent/plugin/in_udp.rb +37 -0
  126. data/lib/fluent/plugin/in_unix.rb +201 -0
  127. data/lib/fluent/plugin/input.rb +33 -0
  128. data/lib/fluent/plugin/multi_output.rb +95 -0
  129. data/lib/fluent/plugin/out_buffered_null.rb +59 -0
  130. data/lib/fluent/plugin/out_buffered_stdout.rb +70 -0
  131. data/lib/fluent/plugin/out_copy.rb +42 -0
  132. data/lib/fluent/plugin/out_exec.rb +114 -0
  133. data/lib/fluent/plugin/out_exec_filter.rb +393 -0
  134. data/lib/fluent/plugin/out_file.rb +167 -0
  135. data/lib/fluent/plugin/out_forward.rb +646 -0
  136. data/lib/fluent/plugin/out_null.rb +27 -0
  137. data/lib/fluent/plugin/out_relabel.rb +28 -0
  138. data/lib/fluent/plugin/out_roundrobin.rb +80 -0
  139. data/lib/fluent/plugin/out_stdout.rb +48 -0
  140. data/lib/fluent/plugin/out_stream.rb +130 -0
  141. data/lib/fluent/plugin/output.rb +1020 -0
  142. data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
  143. data/lib/fluent/plugin/parser.rb +175 -0
  144. data/lib/fluent/plugin/parser_apache.rb +28 -0
  145. data/lib/fluent/plugin/parser_apache2.rb +84 -0
  146. data/lib/fluent/plugin/parser_apache_error.rb +26 -0
  147. data/lib/fluent/plugin/parser_csv.rb +33 -0
  148. data/lib/fluent/plugin/parser_json.rb +79 -0
  149. data/lib/fluent/plugin/parser_ltsv.rb +50 -0
  150. data/lib/fluent/plugin/parser_multiline.rb +104 -0
  151. data/lib/fluent/plugin/parser_nginx.rb +28 -0
  152. data/lib/fluent/plugin/parser_none.rb +36 -0
  153. data/lib/fluent/plugin/parser_regexp.rb +73 -0
  154. data/lib/fluent/plugin/parser_syslog.rb +82 -0
  155. data/lib/fluent/plugin/parser_tsv.rb +37 -0
  156. data/lib/fluent/plugin/socket_util.rb +22 -0
  157. data/lib/fluent/plugin/storage.rb +84 -0
  158. data/lib/fluent/plugin/storage_local.rb +132 -0
  159. data/lib/fluent/plugin/string_util.rb +22 -0
  160. data/lib/fluent/plugin_helper.rb +42 -0
  161. data/lib/fluent/plugin_helper/child_process.rb +298 -0
  162. data/lib/fluent/plugin_helper/compat_parameters.rb +224 -0
  163. data/lib/fluent/plugin_helper/event_emitter.rb +80 -0
  164. data/lib/fluent/plugin_helper/event_loop.rb +118 -0
  165. data/lib/fluent/plugin_helper/formatter.rb +149 -0
  166. data/lib/fluent/plugin_helper/inject.rb +125 -0
  167. data/lib/fluent/plugin_helper/parser.rb +147 -0
  168. data/lib/fluent/plugin_helper/retry_state.rb +177 -0
  169. data/lib/fluent/plugin_helper/storage.rb +331 -0
  170. data/lib/fluent/plugin_helper/thread.rb +147 -0
  171. data/lib/fluent/plugin_helper/timer.rb +90 -0
  172. data/lib/fluent/plugin_id.rb +63 -0
  173. data/lib/fluent/process.rb +504 -0
  174. data/lib/fluent/registry.rb +99 -0
  175. data/lib/fluent/root_agent.rb +314 -0
  176. data/lib/fluent/rpc.rb +94 -0
  177. data/lib/fluent/supervisor.rb +680 -0
  178. data/lib/fluent/system_config.rb +122 -0
  179. data/lib/fluent/test.rb +56 -0
  180. data/lib/fluent/test/base.rb +85 -0
  181. data/lib/fluent/test/driver/base.rb +179 -0
  182. data/lib/fluent/test/driver/base_owned.rb +70 -0
  183. data/lib/fluent/test/driver/base_owner.rb +125 -0
  184. data/lib/fluent/test/driver/event_feeder.rb +98 -0
  185. data/lib/fluent/test/driver/filter.rb +57 -0
  186. data/lib/fluent/test/driver/formatter.rb +30 -0
  187. data/lib/fluent/test/driver/input.rb +31 -0
  188. data/lib/fluent/test/driver/multi_output.rb +52 -0
  189. data/lib/fluent/test/driver/output.rb +76 -0
  190. data/lib/fluent/test/driver/parser.rb +30 -0
  191. data/lib/fluent/test/driver/test_event_router.rb +45 -0
  192. data/lib/fluent/test/filter_test.rb +77 -0
  193. data/lib/fluent/test/formatter_test.rb +65 -0
  194. data/lib/fluent/test/helpers.rb +79 -0
  195. data/lib/fluent/test/input_test.rb +172 -0
  196. data/lib/fluent/test/log.rb +73 -0
  197. data/lib/fluent/test/output_test.rb +156 -0
  198. data/lib/fluent/test/parser_test.rb +70 -0
  199. data/lib/fluent/time.rb +175 -0
  200. data/lib/fluent/timezone.rb +133 -0
  201. data/lib/fluent/unique_id.rb +39 -0
  202. data/lib/fluent/version.rb +21 -0
  203. data/lib/fluent/winsvc.rb +71 -0
  204. data/test/compat/test_calls_super.rb +166 -0
  205. data/test/compat/test_parser.rb +82 -0
  206. data/test/config/assertions.rb +42 -0
  207. data/test/config/test_config_parser.rb +507 -0
  208. data/test/config/test_configurable.rb +1194 -0
  209. data/test/config/test_configure_proxy.rb +386 -0
  210. data/test/config/test_dsl.rb +415 -0
  211. data/test/config/test_element.rb +403 -0
  212. data/test/config/test_literal_parser.rb +297 -0
  213. data/test/config/test_section.rb +184 -0
  214. data/test/config/test_system_config.rb +120 -0
  215. data/test/config/test_types.rb +171 -0
  216. data/test/helper.rb +119 -0
  217. data/test/plugin/data/2010/01/20100102-030405.log +0 -0
  218. data/test/plugin/data/2010/01/20100102-030406.log +0 -0
  219. data/test/plugin/data/2010/01/20100102.log +0 -0
  220. data/test/plugin/data/log/bar +0 -0
  221. data/test/plugin/data/log/foo/bar.log +0 -0
  222. data/test/plugin/data/log/test.log +0 -0
  223. data/test/plugin/test_bare_output.rb +118 -0
  224. data/test/plugin/test_base.rb +75 -0
  225. data/test/plugin/test_buf_file.rb +571 -0
  226. data/test/plugin/test_buf_memory.rb +42 -0
  227. data/test/plugin/test_buffer.rb +1200 -0
  228. data/test/plugin/test_buffer_chunk.rb +168 -0
  229. data/test/plugin/test_buffer_file_chunk.rb +771 -0
  230. data/test/plugin/test_buffer_memory_chunk.rb +265 -0
  231. data/test/plugin/test_file_util.rb +96 -0
  232. data/test/plugin/test_filter.rb +353 -0
  233. data/test/plugin/test_filter_grep.rb +119 -0
  234. data/test/plugin/test_filter_record_transformer.rb +600 -0
  235. data/test/plugin/test_filter_stdout.rb +211 -0
  236. data/test/plugin/test_formatter_csv.rb +94 -0
  237. data/test/plugin/test_formatter_json.rb +30 -0
  238. data/test/plugin/test_formatter_ltsv.rb +52 -0
  239. data/test/plugin/test_formatter_msgpack.rb +28 -0
  240. data/test/plugin/test_formatter_out_file.rb +95 -0
  241. data/test/plugin/test_formatter_single_value.rb +38 -0
  242. data/test/plugin/test_in_debug_agent.rb +28 -0
  243. data/test/plugin/test_in_dummy.rb +188 -0
  244. data/test/plugin/test_in_exec.rb +133 -0
  245. data/test/plugin/test_in_forward.rb +635 -0
  246. data/test/plugin/test_in_gc_stat.rb +39 -0
  247. data/test/plugin/test_in_http.rb +442 -0
  248. data/test/plugin/test_in_monitor_agent.rb +329 -0
  249. data/test/plugin/test_in_object_space.rb +64 -0
  250. data/test/plugin/test_in_syslog.rb +205 -0
  251. data/test/plugin/test_in_tail.rb +1001 -0
  252. data/test/plugin/test_in_tcp.rb +102 -0
  253. data/test/plugin/test_in_udp.rb +121 -0
  254. data/test/plugin/test_in_unix.rb +126 -0
  255. data/test/plugin/test_input.rb +122 -0
  256. data/test/plugin/test_multi_output.rb +180 -0
  257. data/test/plugin/test_out_buffered_null.rb +79 -0
  258. data/test/plugin/test_out_buffered_stdout.rb +122 -0
  259. data/test/plugin/test_out_copy.rb +160 -0
  260. data/test/plugin/test_out_exec.rb +155 -0
  261. data/test/plugin/test_out_exec_filter.rb +262 -0
  262. data/test/plugin/test_out_file.rb +383 -0
  263. data/test/plugin/test_out_forward.rb +590 -0
  264. data/test/plugin/test_out_null.rb +29 -0
  265. data/test/plugin/test_out_relabel.rb +28 -0
  266. data/test/plugin/test_out_roundrobin.rb +146 -0
  267. data/test/plugin/test_out_stdout.rb +92 -0
  268. data/test/plugin/test_out_stream.rb +93 -0
  269. data/test/plugin/test_output.rb +568 -0
  270. data/test/plugin/test_output_as_buffered.rb +1604 -0
  271. data/test/plugin/test_output_as_buffered_overflow.rb +250 -0
  272. data/test/plugin/test_output_as_buffered_retries.rb +839 -0
  273. data/test/plugin/test_output_as_buffered_secondary.rb +817 -0
  274. data/test/plugin/test_output_as_standard.rb +374 -0
  275. data/test/plugin/test_owned_by.rb +35 -0
  276. data/test/plugin/test_parser_apache.rb +42 -0
  277. data/test/plugin/test_parser_apache2.rb +38 -0
  278. data/test/plugin/test_parser_apache_error.rb +45 -0
  279. data/test/plugin/test_parser_base.rb +32 -0
  280. data/test/plugin/test_parser_csv.rb +104 -0
  281. data/test/plugin/test_parser_json.rb +107 -0
  282. data/test/plugin/test_parser_labeled_tsv.rb +129 -0
  283. data/test/plugin/test_parser_multiline.rb +100 -0
  284. data/test/plugin/test_parser_nginx.rb +48 -0
  285. data/test/plugin/test_parser_none.rb +53 -0
  286. data/test/plugin/test_parser_regexp.rb +277 -0
  287. data/test/plugin/test_parser_syslog.rb +66 -0
  288. data/test/plugin/test_parser_time.rb +46 -0
  289. data/test/plugin/test_parser_tsv.rb +121 -0
  290. data/test/plugin/test_storage.rb +167 -0
  291. data/test/plugin/test_storage_local.rb +8 -0
  292. data/test/plugin/test_string_util.rb +26 -0
  293. data/test/plugin_helper/test_child_process.rb +608 -0
  294. data/test/plugin_helper/test_compat_parameters.rb +242 -0
  295. data/test/plugin_helper/test_event_emitter.rb +51 -0
  296. data/test/plugin_helper/test_event_loop.rb +52 -0
  297. data/test/plugin_helper/test_formatter.rb +252 -0
  298. data/test/plugin_helper/test_inject.rb +487 -0
  299. data/test/plugin_helper/test_parser.rb +263 -0
  300. data/test/plugin_helper/test_retry_state.rb +399 -0
  301. data/test/plugin_helper/test_storage.rb +521 -0
  302. data/test/plugin_helper/test_thread.rb +164 -0
  303. data/test/plugin_helper/test_timer.rb +131 -0
  304. data/test/scripts/exec_script.rb +32 -0
  305. data/test/scripts/fluent/plugin/formatter_known.rb +8 -0
  306. data/test/scripts/fluent/plugin/out_test.rb +81 -0
  307. data/test/scripts/fluent/plugin/out_test2.rb +80 -0
  308. data/test/scripts/fluent/plugin/parser_known.rb +4 -0
  309. data/test/test_config.rb +179 -0
  310. data/test/test_configdsl.rb +148 -0
  311. data/test/test_event.rb +329 -0
  312. data/test/test_event_router.rb +331 -0
  313. data/test/test_event_time.rb +184 -0
  314. data/test/test_filter.rb +121 -0
  315. data/test/test_formatter.rb +319 -0
  316. data/test/test_input.rb +31 -0
  317. data/test/test_log.rb +572 -0
  318. data/test/test_match.rb +137 -0
  319. data/test/test_mixin.rb +351 -0
  320. data/test/test_output.rb +214 -0
  321. data/test/test_plugin_classes.rb +136 -0
  322. data/test/test_plugin_helper.rb +81 -0
  323. data/test/test_process.rb +48 -0
  324. data/test/test_root_agent.rb +278 -0
  325. data/test/test_supervisor.rb +339 -0
  326. data/test/test_time_formatter.rb +186 -0
  327. data/test/test_unique_id.rb +47 -0
  328. metadata +823 -0
@@ -0,0 +1,21 @@
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/compat/filter'
18
+
19
+ module Fluent
20
+ Filter = Fluent::Compat::Filter
21
+ end
@@ -0,0 +1,23 @@
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/compat/formatter'
18
+
19
+ module Fluent
20
+ Formatter = Fluent::Compat::Formatter
21
+ TextFormatter = Fluent::Compat::TextFormatter
22
+ # deprecate_constant is ruby 2.3 feature
23
+ end
@@ -0,0 +1,21 @@
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/compat/input'
18
+
19
+ module Fluent
20
+ Input = Fluent::Compat::Input
21
+ end
@@ -0,0 +1,38 @@
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/agent'
18
+
19
+ module Fluent
20
+ class Label < Agent
21
+ def initialize(name, log:)
22
+ super(log: log)
23
+
24
+ @context = name
25
+ @root_agent = nil
26
+ end
27
+
28
+ attr_accessor :root_agent
29
+
30
+ def emit_error_event(tag, time, record, e)
31
+ @root_agent.emit_error_event(tag, time, record, e)
32
+ end
33
+
34
+ def handle_emits_error(tag, es, e)
35
+ @root_agent.handle_emits_error(tag, es, e)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ require 'thread'
2
+ require 'socket'
3
+ require 'fcntl'
4
+ require 'time'
5
+ require 'monitor'
6
+ require 'stringio'
7
+ require 'fileutils'
8
+ require 'json'
9
+ require 'yajl'
10
+ require 'uri'
11
+ require 'msgpack'
12
+ require 'strptime'
13
+ begin
14
+ require 'sigdump/setup'
15
+ rescue
16
+ # ignore setup error on Win or similar platform which doesn't support signal
17
+ end
18
+ require 'cool.io'
19
+
20
+ require 'fluent/time'
21
+ require 'fluent/env'
22
+ require 'fluent/version'
23
+ require 'fluent/log'
24
+ require 'fluent/config'
25
+ require 'fluent/engine'
26
+ require 'fluent/rpc'
27
+ require 'fluent/mixin'
28
+ require 'fluent/process'
29
+ require 'fluent/plugin'
30
+ require 'fluent/parser'
31
+ require 'fluent/formatter'
32
+ require 'fluent/event'
33
+ require 'fluent/input'
34
+ require 'fluent/output'
35
+ require 'fluent/filter'
36
+ require 'fluent/match'
@@ -0,0 +1,445 @@
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 'forwardable'
18
+
19
+ module Fluent
20
+ class Log
21
+ module TTYColor
22
+ RESET = "\033]R"
23
+ CRE = "\033[K"
24
+ CLEAR = "\033c"
25
+ NORMAL = "\033[0;39m"
26
+ RED = "\033[1;31m"
27
+ GREEN = "\033[1;32m"
28
+ YELLOW = "\033[1;33m"
29
+ BLUE = "\033[1;34m"
30
+ MAGENTA = "\033[1;35m"
31
+ CYAN = "\033[1;36m"
32
+ WHITE = "\033[1;37m"
33
+ end
34
+
35
+ LEVEL_TRACE = 0
36
+ LEVEL_DEBUG = 1
37
+ LEVEL_INFO = 2
38
+ LEVEL_WARN = 3
39
+ LEVEL_ERROR = 4
40
+ LEVEL_FATAL = 5
41
+
42
+ LEVEL_TEXT = %w(trace debug info warn error fatal)
43
+
44
+ def self.str_to_level(log_level_str)
45
+ case log_level_str.downcase
46
+ when "trace" then LEVEL_TRACE
47
+ when "debug" then LEVEL_DEBUG
48
+ when "info" then LEVEL_INFO
49
+ when "warn" then LEVEL_WARN
50
+ when "error" then LEVEL_ERROR
51
+ when "fatal" then LEVEL_FATAL
52
+ else raise "Unknown log level: level = #{log_level_str}"
53
+ end
54
+ end
55
+
56
+ def initialize(logger, opts={})
57
+ # overwrites logger.level= so that config reloading resets level of Fluentd::Log
58
+ orig_logger_level_setter = logger.class.public_instance_method(:level=).bind(logger)
59
+ me = self
60
+ # The original ruby logger sets the number as each log level like below.
61
+ # DEBUG = 0
62
+ # INFO = 1
63
+ # WARN = 2
64
+ # ERROR = 3
65
+ # FATAL = 4
66
+ # Serverengine use this original log number. In addition to this, serverengine sets -1 as TRACE level.
67
+ # TRACE = -1
68
+ #
69
+ # On the other hand, in fluentd side, it sets the number like below.
70
+ # TRACE = 0
71
+ # DEBUG = 1
72
+ # INFO = 2
73
+ # WARN = 3
74
+ # ERROR = 4
75
+ # FATAL = 5
76
+ #
77
+ # Then fluentd's level is set as serverengine's level + 1.
78
+ # So if serverengine's logger level is changed, fluentd's log level will be changed to that + 1.
79
+ logger.define_singleton_method(:level=) {|level| orig_logger_level_setter.call(level); me.level = self.level + 1 }
80
+
81
+ @logger = logger
82
+ @out = logger.instance_variable_get(:@logdev)
83
+ @level = logger.level + 1
84
+ @debug_mode = false
85
+ @self_event = false
86
+ @tag = 'fluent'
87
+ @time_format = '%Y-%m-%d %H:%M:%S %z '
88
+ @depth_offset = 1
89
+ enable_color out.tty?
90
+ # TODO: This variable name is unclear so we should change to better name.
91
+ @threads_exclude_events = []
92
+
93
+ # Fluent::Engine requires Fluent::Log, so we must take that object lazily
94
+ @engine = Fluent.const_get('Engine')
95
+ @optional_header = nil
96
+ @optional_attrs = nil
97
+
98
+ @suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
99
+ end
100
+
101
+ def dup
102
+ dl_opts = {}
103
+ dl_opts[:log_level] = @level - 1
104
+ logger = ServerEngine::DaemonLogger.new(@out, dl_opts)
105
+ clone = self.class.new(logger, suppress_repeated_stacktrace: @suppress_repeated_stacktrace)
106
+ clone.tag = @tag
107
+ clone.time_format = @time_format
108
+ # optional headers/attrs are not copied, because new PluginLogger should have another one of it
109
+ clone
110
+ end
111
+
112
+ attr_accessor :out
113
+ attr_accessor :level
114
+ attr_accessor :tag
115
+ attr_accessor :time_format
116
+ attr_accessor :optional_header, :optional_attrs
117
+
118
+ def logdev=(logdev)
119
+ @out = logdev
120
+ @logger.instance_variable_set(:@logdev, logdev)
121
+ nil
122
+ end
123
+
124
+ def reopen!
125
+ # do noting in @logger.reopen! because it's already reopened in Supervisor.load_config
126
+ @logger.reopen! if @logger
127
+ nil
128
+ end
129
+
130
+ def enable_debug(b=true)
131
+ @debug_mode = b
132
+ self
133
+ end
134
+
135
+ def enable_event(b=true)
136
+ @self_event = b
137
+ self
138
+ end
139
+
140
+ def enable_color?
141
+ !@color_reset.empty?
142
+ end
143
+
144
+ def enable_color(b=true)
145
+ if b
146
+ @color_trace = TTYColor::BLUE
147
+ @color_debug = TTYColor::WHITE
148
+ @color_info = TTYColor::GREEN
149
+ @color_warn = TTYColor::YELLOW
150
+ @color_error = TTYColor::MAGENTA
151
+ @color_fatal = TTYColor::RED
152
+ @color_reset = TTYColor::NORMAL
153
+ else
154
+ @color_trace = ''
155
+ @color_debug = ''
156
+ @color_info = ''
157
+ @color_warn = ''
158
+ @color_error = ''
159
+ @color_fatal = ''
160
+ @color_reset = ''
161
+ end
162
+ self
163
+ end
164
+
165
+ # If you want to suppress event emitting in specific thread, please use this method.
166
+ # Events in passed thread are never emitted.
167
+ def disable_events(thread)
168
+ @threads_exclude_events.push(thread) unless @threads_exclude_events.include?(thread)
169
+ end
170
+
171
+ def on_trace(&block)
172
+ return if @level > LEVEL_TRACE
173
+ block.call if block
174
+ end
175
+
176
+ def trace(*args, &block)
177
+ return if @level > LEVEL_TRACE
178
+ args << block.call if block
179
+ time, msg = event(:trace, args)
180
+ puts [@color_trace, caller_line(time, @depth_offset, LEVEL_TRACE), msg, @color_reset].join
181
+ rescue
182
+ # logger should not raise an exception. This rescue prevents unexpected behaviour.
183
+ end
184
+ alias TRACE trace
185
+
186
+ def trace_backtrace(backtrace=$!.backtrace)
187
+ dump_stacktrace(backtrace, LEVEL_TRACE)
188
+ end
189
+
190
+ def on_debug(&block)
191
+ return if @level > LEVEL_DEBUG
192
+ block.call if block
193
+ end
194
+
195
+ def debug(*args, &block)
196
+ return if @level > LEVEL_DEBUG
197
+ args << block.call if block
198
+ time, msg = event(:debug, args)
199
+ puts [@color_debug, caller_line(time, @depth_offset, LEVEL_DEBUG), msg, @color_reset].join
200
+ rescue
201
+ end
202
+ alias DEBUG debug
203
+
204
+ def debug_backtrace(backtrace=$!.backtrace)
205
+ dump_stacktrace(backtrace, LEVEL_DEBUG)
206
+ end
207
+
208
+ def on_info(&block)
209
+ return if @level > LEVEL_INFO
210
+ block.call if block
211
+ end
212
+
213
+ def info(*args, &block)
214
+ return if @level > LEVEL_INFO
215
+ args << block.call if block
216
+ time, msg = event(:info, args)
217
+ puts [@color_info, caller_line(time, @depth_offset, LEVEL_INFO), msg, @color_reset].join
218
+ rescue
219
+ end
220
+ alias INFO info
221
+
222
+ def info_backtrace(backtrace=$!.backtrace)
223
+ dump_stacktrace(backtrace, LEVEL_INFO)
224
+ end
225
+
226
+ def on_warn(&block)
227
+ return if @level > LEVEL_WARN
228
+ block.call if block
229
+ end
230
+
231
+ def warn(*args, &block)
232
+ return if @level > LEVEL_WARN
233
+ args << block.call if block
234
+ time, msg = event(:warn, args)
235
+ puts [@color_warn, caller_line(time, @depth_offset, LEVEL_WARN), msg, @color_reset].join
236
+ rescue
237
+ end
238
+ alias WARN warn
239
+
240
+ def warn_backtrace(backtrace=$!.backtrace)
241
+ dump_stacktrace(backtrace, LEVEL_WARN)
242
+ end
243
+
244
+ def on_error(&block)
245
+ return if @level > LEVEL_ERROR
246
+ block.call if block
247
+ end
248
+
249
+ def error(*args, &block)
250
+ return if @level > LEVEL_ERROR
251
+ args << block.call if block
252
+ time, msg = event(:error, args)
253
+ puts [@color_error, caller_line(time, @depth_offset, LEVEL_ERROR), msg, @color_reset].join
254
+ rescue
255
+ end
256
+ alias ERROR error
257
+
258
+ def error_backtrace(backtrace=$!.backtrace)
259
+ dump_stacktrace(backtrace, LEVEL_ERROR)
260
+ end
261
+
262
+ def on_fatal(&block)
263
+ return if @level > LEVEL_FATAL
264
+ block.call if block
265
+ end
266
+
267
+ def fatal(*args, &block)
268
+ return if @level > LEVEL_FATAL
269
+ args << block.call if block
270
+ time, msg = event(:fatal, args)
271
+ puts [@color_fatal, caller_line(time, @depth_offset, LEVEL_FATAL), msg, @color_reset].join
272
+ rescue
273
+ end
274
+ alias FATAL fatal
275
+
276
+ def fatal_backtrace(backtrace=$!.backtrace)
277
+ dump_stacktrace(backtrace, LEVEL_FATAL)
278
+ end
279
+
280
+ def puts(msg)
281
+ @logger << msg + "\n"
282
+ @out.flush
283
+ msg
284
+ rescue
285
+ # FIXME
286
+ nil
287
+ end
288
+
289
+ def write(data)
290
+ @out.write(data)
291
+ end
292
+
293
+ def flush
294
+ @out.flush
295
+ end
296
+
297
+ def reset
298
+ @out.reset if @out.respond_to?(:reset)
299
+ end
300
+
301
+ private
302
+
303
+ def dump_stacktrace(backtrace, level)
304
+ return if @level > level
305
+
306
+ time = Time.now
307
+ line = caller_line(time, 5, level)
308
+ if @suppress_repeated_stacktrace && (Thread.current[:last_repeated_stacktrace] == backtrace)
309
+ puts [" ", line, 'suppressed same stacktrace'].join
310
+ else
311
+ backtrace.each { |msg|
312
+ puts [" ", line, msg].join
313
+ }
314
+ Thread.current[:last_repeated_stacktrace] = backtrace if @suppress_repeated_stacktrace
315
+ end
316
+
317
+ nil
318
+ end
319
+
320
+ def event(level, args)
321
+ time = Time.now
322
+ message = @optional_header ? @optional_header.dup : ''
323
+ map = @optional_attrs ? @optional_attrs.dup : {}
324
+ args.each {|a|
325
+ if a.is_a?(Hash)
326
+ a.each_pair {|k,v|
327
+ map[k.to_s] = v
328
+ }
329
+ else
330
+ message << a.to_s
331
+ end
332
+ }
333
+
334
+ map.each_pair {|k,v|
335
+ if k == "error".freeze && v.is_a?(Exception) && !map.has_key?("error_class")
336
+ message << " error_class=#{v.class.to_s} error=#{v.to_s.inspect}"
337
+ else
338
+ message << " #{k}=#{v.inspect}"
339
+ end
340
+ }
341
+
342
+ unless @threads_exclude_events.include?(Thread.current)
343
+ record = map.dup
344
+ record.keys.each {|key|
345
+ record[key] = record[key].inspect unless record[key].respond_to?(:to_msgpack)
346
+ }
347
+ record['message'] = message.dup
348
+ @engine.push_log_event("#{@tag}.#{level}", time.to_i, record)
349
+ end
350
+
351
+ return time, message
352
+ end
353
+
354
+ def caller_line(time, depth, level)
355
+ log_msg = "#{time.strftime(@time_format)}[#{LEVEL_TEXT[level]}]: "
356
+ if @debug_mode
357
+ line = caller(depth+1)[0]
358
+ if match = /^(.+?):(\d+)(?::in `(.*)')?/.match(line)
359
+ file = match[1].split('/')[-2,2].join('/')
360
+ line = match[2]
361
+ method = match[3]
362
+ return "#{log_msg}#{file}:#{line}:#{method}: "
363
+ end
364
+ end
365
+ return log_msg
366
+ end
367
+ end
368
+
369
+
370
+ # PluginLogger has own log level separated from global $log object.
371
+ # This class enables log_level option in each plugin.
372
+ #
373
+ # PluginLogger has same functionality as Log but some methods are forwarded to internal logger
374
+ # for keeping logging action consistency in the process, e.g. color, tag, event, etc.
375
+ class PluginLogger < Log
376
+ def initialize(logger)
377
+ @logger = logger
378
+ @level = @logger.level
379
+ @depth_offset = 2
380
+ if logger.instance_variable_defined?(:@suppress_repeated_stacktrace)
381
+ @suppress_repeated_stacktrace = logger.instance_variable_get(:@suppress_repeated_stacktrace)
382
+ end
383
+
384
+ enable_color @logger.enable_color?
385
+ end
386
+
387
+ def level=(log_level_str)
388
+ @level = Log.str_to_level(log_level_str)
389
+ end
390
+
391
+ alias orig_enable_color enable_color
392
+
393
+ def enable_color(b = true)
394
+ orig_enable_color b
395
+ @logger.enable_color b
396
+ end
397
+
398
+ extend Forwardable
399
+ def_delegators '@logger', :enable_color?, :enable_debug, :enable_event,
400
+ :disable_events, :tag, :tag=, :time_format, :time_format=,
401
+ :event, :caller_line, :puts, :write, :flush, :reset, :out, :out=,
402
+ :optional_header, :optional_header=, :optional_attrs, :optional_attrs=
403
+ end
404
+
405
+
406
+ module PluginLoggerMixin
407
+ def self.included(klass)
408
+ klass.instance_eval {
409
+ desc 'Allows the user to set different levels of logging for each plugin.'
410
+ config_param :@log_level, :string, default: nil, alias: :log_level # 'log_level' will be warned as deprecated
411
+ }
412
+ end
413
+
414
+ def initialize
415
+ super
416
+
417
+ @log = $log # Use $log object directly by default
418
+ end
419
+
420
+ attr_accessor :log
421
+
422
+ def configure(conf)
423
+ super
424
+
425
+ if level = conf['@log_level']
426
+ unless @log.is_a?(PluginLogger)
427
+ @log = PluginLogger.new($log.dup)
428
+ end
429
+ @log.level = level
430
+ @log.optional_header = "[#{self.class.name}#{plugin_id_configured? ? "(" + @id + ")" : ""}] "
431
+ @log.optional_attrs = {}
432
+ end
433
+ end
434
+
435
+ def start
436
+ @log.reset
437
+ super
438
+ end
439
+
440
+ def terminate
441
+ super
442
+ @log.reset
443
+ end
444
+ end
445
+ end