53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/logstash/config/source/local.rb', line 53
def read
config_parts = []
encoding_issue_files = []
if logger.debug?
logger.debug("Skipping the following files while reading config since they don't match the specified glob pattern", :files => get_unmatched_files)
end
get_matched_files.each do |file|
next unless ::File.file?(file)
logger.debug("Reading config file", :config_file => file)
if temporary_file?(file)
logger.warn("NOT reading config file because it is a temp file", :config_file => file)
next
end
config_string = ::File.read(file)
config_string.force_encoding("UTF-8")
if config_string.valid_encoding?
part = org.logstash.common.SourceWithMetadata.new("file", file, 0, 0, config_string)
config_parts << part
else
encoding_issue_files << file
end
end
if encoding_issue_files.any?
raise LogStash::ConfigLoadingError, "The following config files contains non-ascii characters but are not UTF-8 encoded #{encoding_issue_files}"
end
if config_parts.empty?
logger.info("No config files found in path", :path => path)
end
config_parts
end
|