Skip to content

Commit

Permalink
in_http: Add dump_error_log parameter. fix #3035
Browse files Browse the repository at this point in the history
Signed-off-by: Masahiro Nakagawa <repeatedly@gmail.com>
  • Loading branch information
repeatedly committed Jun 11, 2020
1 parent f5cc777 commit 77efefc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/fluent/plugin/in_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class HttpInput < Input
config_param :respond_with_empty_img, :bool, default: false
desc 'Respond status code with 204.'
config_param :use_204_response, :bool, default: false
desc 'Dump error log or not'
config_param :dump_error_log, :bool, default: true

config_section :parse do
config_set_default :@type, 'in_http'
Expand Down Expand Up @@ -180,8 +182,11 @@ def on_request(path_info, params)
else
record_time.nil? ? Fluent::EventTime.now : record_time
end
rescue
return ["400 Bad Request", {'Content-Type'=>'text/plain'}, "400 Bad Request\n#{$!}\n"]
rescue => e
if @dump_error_log
log.error "failed to process request", error: e
end
return ["400 Bad Request", {'Content-Type'=>'text/plain'}, "400 Bad Request\n#{e}\n"]
end

# TODO server error
Expand Down Expand Up @@ -218,8 +223,11 @@ def on_request(path_info, params)
else
router.emit(tag, time, record)
end
rescue
return ["500 Internal Server Error", {'Content-Type'=>'text/plain'}, "500 Internal Server Error\n#{$!}\n"]
rescue => e
if @dump_error_log
log.error "failed to emit data", error: e
end
return ["500 Internal Server Error", {'Content-Type'=>'text/plain'}, "500 Internal Server Error\n#{e}\n"]
end

if @respond_with_empty_img
Expand Down

0 comments on commit 77efefc

Please sign in to comment.