fluentd 1.15.2-x86-mingw32 → 1.16.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +1 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +1 -0
- data/.github/workflows/linux-test.yaml +2 -2
- data/.github/workflows/macos-test.yaml +2 -2
- data/.github/workflows/stale-actions.yml +11 -9
- data/.github/workflows/windows-test.yaml +2 -2
- data/CHANGELOG.md +133 -0
- data/CONTRIBUTING.md +1 -1
- data/MAINTAINERS.md +5 -3
- data/README.md +0 -1
- data/SECURITY.md +5 -9
- data/fluentd.gemspec +2 -2
- data/lib/fluent/command/fluentd.rb +55 -64
- data/lib/fluent/config/yaml_parser/loader.rb +18 -1
- data/lib/fluent/daemon.rb +2 -4
- data/lib/fluent/event.rb +2 -2
- data/lib/fluent/file_wrapper.rb +137 -0
- data/lib/fluent/log/console_adapter.rb +66 -0
- data/lib/fluent/log.rb +35 -5
- data/lib/fluent/oj_options.rb +1 -2
- data/lib/fluent/plugin/base.rb +5 -7
- data/lib/fluent/plugin/buf_file.rb +32 -3
- data/lib/fluent/plugin/buf_file_single.rb +32 -3
- data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
- data/lib/fluent/plugin/buffer.rb +21 -0
- data/lib/fluent/plugin/in_tail.rb +1 -6
- data/lib/fluent/plugin/in_tcp.rb +47 -2
- data/lib/fluent/plugin/out_file.rb +0 -4
- data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
- data/lib/fluent/plugin/out_forward.rb +2 -2
- data/lib/fluent/plugin/out_secondary_file.rb +39 -22
- data/lib/fluent/plugin/output.rb +49 -12
- data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
- data/lib/fluent/plugin_helper/server.rb +8 -0
- data/lib/fluent/supervisor.rb +157 -232
- data/lib/fluent/test/driver/base.rb +11 -5
- data/lib/fluent/test/driver/filter.rb +4 -0
- data/lib/fluent/test/startup_shutdown.rb +6 -8
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/test/helper.rb.erb +0 -1
- data/test/command/test_ctl.rb +1 -1
- data/test/command/test_fluentd.rb +168 -22
- data/test/command/test_plugin_config_formatter.rb +0 -1
- data/test/compat/test_parser.rb +5 -5
- data/test/config/test_system_config.rb +0 -8
- data/test/log/test_console_adapter.rb +110 -0
- data/test/plugin/out_forward/test_ack_handler.rb +39 -0
- data/test/plugin/test_base.rb +98 -0
- data/test/plugin/test_buf_file.rb +62 -23
- data/test/plugin/test_buf_file_single.rb +65 -0
- data/test/plugin/test_in_http.rb +2 -3
- data/test/plugin/test_in_monitor_agent.rb +2 -3
- data/test/plugin/test_in_tail.rb +105 -103
- data/test/plugin/test_in_tcp.rb +87 -2
- data/test/plugin/test_in_udp.rb +28 -0
- data/test/plugin/test_out_file.rb +3 -2
- data/test/plugin/test_out_forward.rb +14 -18
- data/test/plugin/test_out_http.rb +1 -0
- data/test/plugin/test_output.rb +269 -0
- data/test/plugin/test_output_as_buffered_compress.rb +32 -18
- data/test/plugin/test_parser_regexp.rb +1 -6
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +59 -5
- data/test/test_config.rb +57 -21
- data/test/{plugin/test_file_wrapper.rb → test_file_wrapper.rb} +2 -2
- data/test/test_formatter.rb +23 -20
- data/test/test_log.rb +85 -40
- data/test/test_supervisor.rb +300 -283
- metadata +15 -23
- data/.drone.yml +0 -35
- data/.github/workflows/issue-auto-closer.yml +0 -12
- data/.gitlab-ci.yml +0 -103
- data/lib/fluent/plugin/file_wrapper.rb +0 -131
- data/test/test_logger_initializer.rb +0 -46
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluentd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,7 @@ dependencies:
|
|
84
84
|
requirements:
|
85
85
|
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: 2.3.
|
87
|
+
version: 2.3.2
|
88
88
|
- - "<"
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 3.0.0
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 2.3.
|
97
|
+
version: 2.3.2
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 3.0.0
|
@@ -190,22 +190,16 @@ dependencies:
|
|
190
190
|
name: webrick
|
191
191
|
requirement: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
|
-
- - "
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: 1.4.2
|
196
|
-
- - "<"
|
193
|
+
- - "~>"
|
197
194
|
- !ruby/object:Gem::Version
|
198
|
-
version: 1.
|
195
|
+
version: '1.4'
|
199
196
|
type: :runtime
|
200
197
|
prerelease: false
|
201
198
|
version_requirements: !ruby/object:Gem::Requirement
|
202
199
|
requirements:
|
203
|
-
- - "
|
204
|
-
- !ruby/object:Gem::Version
|
205
|
-
version: 1.4.2
|
206
|
-
- - "<"
|
200
|
+
- - "~>"
|
207
201
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.
|
202
|
+
version: '1.4'
|
209
203
|
- !ruby/object:Gem::Dependency
|
210
204
|
name: win32-service
|
211
205
|
requirement: !ruby/object:Gem::Requirement
|
@@ -441,19 +435,16 @@ extensions: []
|
|
441
435
|
extra_rdoc_files: []
|
442
436
|
files:
|
443
437
|
- ".deepsource.toml"
|
444
|
-
- ".drone.yml"
|
445
438
|
- ".github/ISSUE_TEMPLATE.md"
|
446
439
|
- ".github/ISSUE_TEMPLATE/bug_report.yaml"
|
447
440
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
448
441
|
- ".github/ISSUE_TEMPLATE/feature_request.yaml"
|
449
442
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
450
|
-
- ".github/workflows/issue-auto-closer.yml"
|
451
443
|
- ".github/workflows/linux-test.yaml"
|
452
444
|
- ".github/workflows/macos-test.yaml"
|
453
445
|
- ".github/workflows/stale-actions.yml"
|
454
446
|
- ".github/workflows/windows-test.yaml"
|
455
447
|
- ".gitignore"
|
456
|
-
- ".gitlab-ci.yml"
|
457
448
|
- ADOPTERS.md
|
458
449
|
- AUTHORS
|
459
450
|
- CHANGELOG.md
|
@@ -585,6 +576,7 @@ files:
|
|
585
576
|
- lib/fluent/event.rb
|
586
577
|
- lib/fluent/event_router.rb
|
587
578
|
- lib/fluent/ext_monitor_require.rb
|
579
|
+
- lib/fluent/file_wrapper.rb
|
588
580
|
- lib/fluent/filter.rb
|
589
581
|
- lib/fluent/fluent_log_event_router.rb
|
590
582
|
- lib/fluent/formatter.rb
|
@@ -592,6 +584,7 @@ files:
|
|
592
584
|
- lib/fluent/label.rb
|
593
585
|
- lib/fluent/load.rb
|
594
586
|
- lib/fluent/log.rb
|
587
|
+
- lib/fluent/log/console_adapter.rb
|
595
588
|
- lib/fluent/match.rb
|
596
589
|
- lib/fluent/mixin.rb
|
597
590
|
- lib/fluent/msgpack_factory.rb
|
@@ -613,7 +606,6 @@ files:
|
|
613
606
|
- lib/fluent/plugin/compressable.rb
|
614
607
|
- lib/fluent/plugin/exec_util.rb
|
615
608
|
- lib/fluent/plugin/file_util.rb
|
616
|
-
- lib/fluent/plugin/file_wrapper.rb
|
617
609
|
- lib/fluent/plugin/filter.rb
|
618
610
|
- lib/fluent/plugin/filter_grep.rb
|
619
611
|
- lib/fluent/plugin/filter_parser.rb
|
@@ -814,6 +806,7 @@ files:
|
|
814
806
|
- test/helper.rb
|
815
807
|
- test/helpers/fuzzy_assert.rb
|
816
808
|
- test/helpers/process_extenstion.rb
|
809
|
+
- test/log/test_console_adapter.rb
|
817
810
|
- test/plugin/data/2010/01/20100102-030405.log
|
818
811
|
- test/plugin/data/2010/01/20100102-030406.log
|
819
812
|
- test/plugin/data/2010/01/20100102.log
|
@@ -846,7 +839,6 @@ files:
|
|
846
839
|
- test/plugin/test_buffer_memory_chunk.rb
|
847
840
|
- test/plugin/test_compressable.rb
|
848
841
|
- test/plugin/test_file_util.rb
|
849
|
-
- test/plugin/test_file_wrapper.rb
|
850
842
|
- test/plugin/test_filter.rb
|
851
843
|
- test/plugin/test_filter_grep.rb
|
852
844
|
- test/plugin/test_filter_parser.rb
|
@@ -978,12 +970,12 @@ files:
|
|
978
970
|
- test/test_event.rb
|
979
971
|
- test/test_event_router.rb
|
980
972
|
- test/test_event_time.rb
|
973
|
+
- test/test_file_wrapper.rb
|
981
974
|
- test/test_filter.rb
|
982
975
|
- test/test_fluent_log_event_router.rb
|
983
976
|
- test/test_formatter.rb
|
984
977
|
- test/test_input.rb
|
985
978
|
- test/test_log.rb
|
986
|
-
- test/test_logger_initializer.rb
|
987
979
|
- test/test_match.rb
|
988
980
|
- test/test_mixin.rb
|
989
981
|
- test/test_msgpack_factory.rb
|
@@ -1022,7 +1014,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1022
1014
|
- !ruby/object:Gem::Version
|
1023
1015
|
version: '0'
|
1024
1016
|
requirements: []
|
1025
|
-
rubygems_version: 3.3.
|
1017
|
+
rubygems_version: 3.3.5
|
1026
1018
|
signing_key:
|
1027
1019
|
specification_version: 4
|
1028
1020
|
summary: Fluentd event collector
|
@@ -1057,6 +1049,7 @@ test_files:
|
|
1057
1049
|
- test/helper.rb
|
1058
1050
|
- test/helpers/fuzzy_assert.rb
|
1059
1051
|
- test/helpers/process_extenstion.rb
|
1052
|
+
- test/log/test_console_adapter.rb
|
1060
1053
|
- test/plugin/data/2010/01/20100102-030405.log
|
1061
1054
|
- test/plugin/data/2010/01/20100102-030406.log
|
1062
1055
|
- test/plugin/data/2010/01/20100102.log
|
@@ -1089,7 +1082,6 @@ test_files:
|
|
1089
1082
|
- test/plugin/test_buffer_memory_chunk.rb
|
1090
1083
|
- test/plugin/test_compressable.rb
|
1091
1084
|
- test/plugin/test_file_util.rb
|
1092
|
-
- test/plugin/test_file_wrapper.rb
|
1093
1085
|
- test/plugin/test_filter.rb
|
1094
1086
|
- test/plugin/test_filter_grep.rb
|
1095
1087
|
- test/plugin/test_filter_parser.rb
|
@@ -1221,12 +1213,12 @@ test_files:
|
|
1221
1213
|
- test/test_event.rb
|
1222
1214
|
- test/test_event_router.rb
|
1223
1215
|
- test/test_event_time.rb
|
1216
|
+
- test/test_file_wrapper.rb
|
1224
1217
|
- test/test_filter.rb
|
1225
1218
|
- test/test_fluent_log_event_router.rb
|
1226
1219
|
- test/test_formatter.rb
|
1227
1220
|
- test/test_input.rb
|
1228
1221
|
- test/test_log.rb
|
1229
|
-
- test/test_logger_initializer.rb
|
1230
1222
|
- test/test_match.rb
|
1231
1223
|
- test/test_mixin.rb
|
1232
1224
|
- test/test_msgpack_factory.rb
|
data/.drone.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
kind: pipeline
|
2
|
-
name: fluentd-test-arm64-3-0
|
3
|
-
|
4
|
-
platform:
|
5
|
-
os: linux
|
6
|
-
arch: arm64
|
7
|
-
|
8
|
-
steps:
|
9
|
-
- name: fluentd-test-arm64-3-0
|
10
|
-
image: arm64v8/ruby:3.0
|
11
|
-
commands:
|
12
|
-
- apt update
|
13
|
-
- apt -y install libgmp3-dev
|
14
|
-
- export BUNDLE_GEMFILE=$PWD/Gemfile
|
15
|
-
- gem update --system
|
16
|
-
- bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
17
|
-
- bundle exec rake test
|
18
|
-
---
|
19
|
-
kind: pipeline
|
20
|
-
name: fluentd-test-arm64-2-7
|
21
|
-
|
22
|
-
platform:
|
23
|
-
os: linux
|
24
|
-
arch: arm64
|
25
|
-
|
26
|
-
steps:
|
27
|
-
- name: fluentd-test-arm64-2-7
|
28
|
-
image: arm64v8/ruby:2.7
|
29
|
-
commands:
|
30
|
-
- apt update
|
31
|
-
- apt -y install libgmp3-dev
|
32
|
-
- export BUNDLE_GEMFILE=$PWD/Gemfile
|
33
|
-
- gem update --system
|
34
|
-
- bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
35
|
-
- bundle exec rake test
|
@@ -1,12 +0,0 @@
|
|
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.*)"
|
data/.gitlab-ci.yml
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
.install-template:
|
2
|
-
before_script:
|
3
|
-
- gem update --system
|
4
|
-
- ruby -v
|
5
|
-
|
6
|
-
.test-template:
|
7
|
-
before_script:
|
8
|
-
- gem install rake
|
9
|
-
- bundle install
|
10
|
-
- chmod 777 -R ./test
|
11
|
-
|
12
|
-
stages:
|
13
|
-
- build
|
14
|
-
- tests
|
15
|
-
|
16
|
-
2-6-6:
|
17
|
-
image: "ruby:2.6.6"
|
18
|
-
stage: build
|
19
|
-
extends: .install-template
|
20
|
-
script:
|
21
|
-
- bundle install --jobs=3 --retry=3
|
22
|
-
cache:
|
23
|
-
key: "$CI_COMMIT_REF_SLUG 2-6-6"
|
24
|
-
paths:
|
25
|
-
|
26
|
-
2-7-2:
|
27
|
-
image: "ruby:2.7.2"
|
28
|
-
stage: build
|
29
|
-
extends: .install-template
|
30
|
-
script:
|
31
|
-
- bundle install --jobs=3 --retry=3
|
32
|
-
cache:
|
33
|
-
key: "$CI_COMMIT_REF_SLUG 2-7-2"
|
34
|
-
paths:
|
35
|
-
|
36
|
-
3-0-0:
|
37
|
-
image: "ruby:3.0.0"
|
38
|
-
stage: build
|
39
|
-
extends: .install-template
|
40
|
-
script:
|
41
|
-
- bundle install --jobs=3 --retry=3
|
42
|
-
cache:
|
43
|
-
key: "$CI_COMMIT_REF_SLUG 3-0-0"
|
44
|
-
paths:
|
45
|
-
|
46
|
-
rubyhead:
|
47
|
-
image: "ruby:latest"
|
48
|
-
stage: build
|
49
|
-
extends: .install-template
|
50
|
-
script:
|
51
|
-
- bundle install --jobs=3 --retry=3
|
52
|
-
cache:
|
53
|
-
key: "$CI_COMMIT_REF_SLUG latest"
|
54
|
-
paths:
|
55
|
-
- ./*
|
56
|
-
|
57
|
-
2-6-6-test:
|
58
|
-
image: "ruby:2.6.6"
|
59
|
-
stage: tests
|
60
|
-
allow_failure: true
|
61
|
-
extends: .test-template
|
62
|
-
script:
|
63
|
-
- bundle exec rake test
|
64
|
-
cache:
|
65
|
-
key: "$CI_COMMIT_REF_SLUG 2-6-6"
|
66
|
-
paths:
|
67
|
-
- ./*
|
68
|
-
|
69
|
-
2-7-2-test:
|
70
|
-
image: "ruby:2.7.2"
|
71
|
-
stage: tests
|
72
|
-
allow_failure: true
|
73
|
-
extends: .test-template
|
74
|
-
script:
|
75
|
-
- bundle exec rake test
|
76
|
-
cache:
|
77
|
-
key: "$CI_COMMIT_REF_SLUG 2-7-2"
|
78
|
-
paths:
|
79
|
-
- ./*
|
80
|
-
|
81
|
-
3-0-0-test:
|
82
|
-
image: "ruby:3.0.0"
|
83
|
-
stage: tests
|
84
|
-
allow_failure: true
|
85
|
-
extends: .test-template
|
86
|
-
script:
|
87
|
-
- bundle exec rake test
|
88
|
-
cache:
|
89
|
-
key: "$CI_COMMIT_REF_SLUG 3-0-0"
|
90
|
-
paths:
|
91
|
-
- ./*
|
92
|
-
|
93
|
-
rubyhead-test:
|
94
|
-
image: "ruby:latest"
|
95
|
-
stage: tests
|
96
|
-
allow_failure: true
|
97
|
-
extends: .test-template
|
98
|
-
script:
|
99
|
-
- bundle exec rake test
|
100
|
-
cache:
|
101
|
-
key: "$CI_COMMIT_REF_SLUG latest"
|
102
|
-
paths:
|
103
|
-
- ./*
|
@@ -1,131 +0,0 @@
|
|
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/win32api'
|
18
|
-
|
19
|
-
module Fluent
|
20
|
-
module FileWrapper
|
21
|
-
def self.open(path, mode='r')
|
22
|
-
io = WindowsFile.new(path, mode).io
|
23
|
-
if block_given?
|
24
|
-
v = yield io
|
25
|
-
io.close
|
26
|
-
v
|
27
|
-
else
|
28
|
-
io
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.stat(path)
|
33
|
-
f = WindowsFile.new(path)
|
34
|
-
s = f.stat
|
35
|
-
f.close
|
36
|
-
s
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class WindowsFile
|
41
|
-
include File::Constants
|
42
|
-
|
43
|
-
attr_reader :io
|
44
|
-
|
45
|
-
INVALID_HANDLE_VALUE = -1
|
46
|
-
|
47
|
-
def initialize(path, mode='r')
|
48
|
-
@path = path
|
49
|
-
@io = File.open(path, mode2flags(mode))
|
50
|
-
@file_handle = Win32API._get_osfhandle(@io.to_i)
|
51
|
-
@io.instance_variable_set(:@file_index, self.ino)
|
52
|
-
def @io.ino
|
53
|
-
@file_index
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def close
|
58
|
-
@io.close
|
59
|
-
@file_handle = INVALID_HANDLE_VALUE
|
60
|
-
end
|
61
|
-
|
62
|
-
# To keep backward compatibility, we continue to use GetFileInformationByHandle()
|
63
|
-
# to get file id.
|
64
|
-
# Note that Ruby's File.stat uses GetFileInformationByHandleEx() with FileIdInfo
|
65
|
-
# and returned value is different with above one, former one is 64 bit while
|
66
|
-
# later one is 128bit.
|
67
|
-
def ino
|
68
|
-
by_handle_file_information = '\0'*(4+8+8+8+4+4+4+4+4+4) #72bytes
|
69
|
-
|
70
|
-
unless Win32API.GetFileInformationByHandle(@file_handle, by_handle_file_information)
|
71
|
-
return 0
|
72
|
-
end
|
73
|
-
|
74
|
-
by_handle_file_information.unpack("I11Q1")[11] # fileindex
|
75
|
-
end
|
76
|
-
|
77
|
-
def stat
|
78
|
-
raise Errno::ENOENT if delete_pending
|
79
|
-
s = File.stat(@path)
|
80
|
-
s.instance_variable_set :@ino, self.ino
|
81
|
-
def s.ino; @ino; end
|
82
|
-
s
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def mode2flags(mode)
|
88
|
-
# Always inject File::Constants::SHARE_DELETE
|
89
|
-
# https://github.com/fluent/fluentd/pull/3585#issuecomment-1101502617
|
90
|
-
# To enable SHARE_DELETE, BINARY is also required.
|
91
|
-
# https://bugs.ruby-lang.org/issues/11218
|
92
|
-
# https://github.com/ruby/ruby/blob/d6684f063bc53e3cab025bd39526eca3b480b5e7/win32/win32.c#L6332-L6345
|
93
|
-
flags = BINARY | SHARE_DELETE
|
94
|
-
case mode.delete("b")
|
95
|
-
when "r"
|
96
|
-
flags |= RDONLY
|
97
|
-
when "r+"
|
98
|
-
flags |= RDWR
|
99
|
-
when "w"
|
100
|
-
flags |= WRONLY | CREAT | TRUNC
|
101
|
-
when "w+"
|
102
|
-
flags |= RDWR | CREAT | TRUNC
|
103
|
-
when "a"
|
104
|
-
flags |= WRONLY | CREAT | APPEND
|
105
|
-
when "a+"
|
106
|
-
flags |= RDWR | CREAT | APPEND
|
107
|
-
else
|
108
|
-
raise Errno::EINVAL.new("Unsupported mode by Fluent::FileWrapper: #{mode}")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# DeletePending is a Windows-specific file state that roughly means
|
113
|
-
# "this file is queued for deletion, so close any open handlers"
|
114
|
-
#
|
115
|
-
# This flag can be retrieved via GetFileInformationByHandleEx().
|
116
|
-
#
|
117
|
-
# https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfileinformationbyhandleex
|
118
|
-
#
|
119
|
-
def delete_pending
|
120
|
-
file_standard_info = 0x01
|
121
|
-
bufsize = 1024
|
122
|
-
buf = '\0' * bufsize
|
123
|
-
|
124
|
-
unless Win32API.GetFileInformationByHandleEx(@file_handle, file_standard_info, buf, bufsize)
|
125
|
-
return false
|
126
|
-
end
|
127
|
-
|
128
|
-
return buf.unpack("QQICC")[3] != 0
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end if Fluent.windows?
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'fluent/supervisor'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class LoggerInitializerTest < ::Test::Unit::TestCase
|
6
|
-
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/logger_initializer#{ENV['TEST_ENV_NUMBER']}")
|
7
|
-
|
8
|
-
teardown do
|
9
|
-
begin
|
10
|
-
FileUtils.rm_rf(TMP_DIR)
|
11
|
-
rescue => _
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
test 'when path is given' do
|
16
|
-
path = File.join(TMP_DIR, 'fluent_with_path.log')
|
17
|
-
|
18
|
-
assert_false File.exist?(TMP_DIR)
|
19
|
-
logger = Fluent::Supervisor::LoggerInitializer.new(path, Fluent::Log::LEVEL_DEBUG, nil, nil, {})
|
20
|
-
mock.proxy(File).chmod(0o777, TMP_DIR).never
|
21
|
-
|
22
|
-
assert_nothing_raised do
|
23
|
-
logger.init(:supervisor, 0)
|
24
|
-
end
|
25
|
-
|
26
|
-
assert_true File.exist?(TMP_DIR)
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'apply_options with log_dir_perm' do
|
30
|
-
omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
|
31
|
-
|
32
|
-
path = File.join(TMP_DIR, 'fluent_with_path.log')
|
33
|
-
|
34
|
-
assert_false File.exist?(TMP_DIR)
|
35
|
-
logger = Fluent::Supervisor::LoggerInitializer.new(path, Fluent::Log::LEVEL_DEBUG, nil, nil, {})
|
36
|
-
mock.proxy(File).chmod(0o777, TMP_DIR).once
|
37
|
-
|
38
|
-
assert_nothing_raised do
|
39
|
-
logger.init(:supervisor, 0)
|
40
|
-
end
|
41
|
-
|
42
|
-
logger.apply_options(log_dir_perm: 0o777)
|
43
|
-
assert_true File.exist?(TMP_DIR)
|
44
|
-
assert_equal 0o777, (File.stat(TMP_DIR).mode & 0xFFF)
|
45
|
-
end
|
46
|
-
end
|