Skip to content

Commit

Permalink
Slice the response body of the log
Browse files Browse the repository at this point in the history
  • Loading branch information
otoyo committed Nov 12, 2017
1 parent db1e458 commit e434367
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/zendesk_api/middleware/response/logger.rb
Expand Up @@ -4,6 +4,8 @@ module Response
# Faraday middleware to handle logging
# @private
class Logger < Faraday::Middleware
LOG_LENGTH = 1000

def initialize(app, logger = nil)
super(app)

Expand All @@ -19,7 +21,7 @@ def call(env)

@app.call(env).on_complete do |env|
info = "Status #{env[:status]}"
info.concat(" #{env[:body].inspect}") if (400..499).cover?(env[:status].to_i)
info.concat(" #{env[:body].to_s[0, LOG_LENGTH]}") if (400..499).cover?(env[:status].to_i)

@logger.info info
@logger.debug dump_debug(env, :response_headers)
Expand Down

0 comments on commit e434367

Please sign in to comment.