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 d94cb51
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 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 @@ -219,6 +224,9 @@ def on_request(path_info, params)
router.emit(tag, time, record)
end
rescue
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#{$!}\n"]
end

Expand Down

0 comments on commit d94cb51

Please sign in to comment.