Skip to content

Commit

Permalink
parser_json: fix wrong LoadError warning
Browse files Browse the repository at this point in the history
If Oj is not installed, LoadError with the empty message is raised.
So, the current condition `/\boj\z/.match?(ex.message)` does not work
and the following meaningless warning is displayed.

    {datetime} [warn]: #x {id} LoadError

After this fix, the log message will be:

    {datetime} [info]: #x {id} Oj is not installed, and failing back to
    Yajl for json parser

Signed-off-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
daipom committed Jun 6, 2024
1 parent 0d9f3a6 commit b25e989
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fluent/plugin/parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def configure_json_parser(name)
raise "BUG: unknown json parser specified: #{name}"
end
rescue LoadError => ex
name = :yajl
if log
if /\boj\z/.match?(ex.message)
if name == :oj
log.info "Oj is not installed, and failing back to Yajl for json parser"
else
log.warn ex.message
end
end
name = :yajl
retry
end

Expand Down

0 comments on commit b25e989

Please sign in to comment.