You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated: StringUtil.match_regexp is now easy to replace with Fluent::Plugin::Base#string_safe_encoding.
There are still Fluent::FileUtil.writable? and #writable_p?.
Fluent::Plugin::StringUtil.match_regexp (implementation was moved to Fluent::Compat::StringUtil now) has some implementation problem:
it provides encode-safety about regular expression matching, but method name doesn't show it
it uses $log, but should use plugin logger
scrubbing strings is very universal process: not only for regular expression matching
My idea is to add a method like this:
defensure_safe_encoding(str)beginyieldstrrescueArgumentError=>eraiseeunlesse.message.include?("invalid byte sequence in".freeze)log.info"invalid byte sequence is replaced in `#{string}`"str=str.scrub('?')retryendend
We can use this method like below:
m=ensure_safe_encoding(line){|s| s =~ /my pattern/}# or other methods or ...chars=ensure_safe_encoding(line){|s| s.split}
Blockers for implementation are:
Naming problem of the method
Namespace? lib/fluent? lib/fluent/util? or...
Should it be a method of Fluent::Plugin::Base? plugin helper? (If true, we'll have so many helpers...) or just Mixin? (We're eliminating mixins, but...)
The text was updated successfully, but these errors were encountered:
Updated: StringUtil.match_regexp is now easy to replace with
Fluent::Plugin::Base#string_safe_encoding
.There are still
Fluent::FileUtil.writable?
and#writable_p?
.Fluent::Plugin::StringUtil.match_regexp
(implementation was moved toFluent::Compat::StringUtil
now) has some implementation problem:$log
, but should use plugin loggerMy idea is to add a method like this:
We can use this method like below:
Blockers for implementation are:
lib/fluent
?lib/fluent/util
? or...Fluent::Plugin::Base
? plugin helper? (If true, we'll have so many helpers...) or just Mixin? (We're eliminating mixins, but...)The text was updated successfully, but these errors were encountered: