class Tumugi::Plugin::Webhook::Logger
Attributes
logger[R]
Public Class Methods
new(app, logger)
click to toggle source
Calls superclass method
# File lib/tumugi/plugin/webhook/logger.rb, line 10 def initialize(app, logger) super(app) @logger = logger end
Public Instance Methods
call(env)
click to toggle source
Calls superclass method
# File lib/tumugi/plugin/webhook/logger.rb, line 15 def call(env) logger.info { "#{env[:method].upcase} #{env[:url]}" } log_request(env) super end
log(headers, body)
click to toggle source
# File lib/tumugi/plugin/webhook/logger.rb, line 35 def log(headers, body) logger.debug { JSON.generate( headers: headers, body: body ) } end
log_request(env)
click to toggle source
# File lib/tumugi/plugin/webhook/logger.rb, line 27 def log_request(env) log(env[:request_headers], env[:body]) end
log_response(env)
click to toggle source
# File lib/tumugi/plugin/webhook/logger.rb, line 31 def log_response(env) log(env[:response_headers], env[:body]) end
log_response_status(status, &block)
click to toggle source
# File lib/tumugi/plugin/webhook/logger.rb, line 44 def log_response_status(status, &block) case status when 200..399 logger.info(&block) else logger.error(&block) end end
on_complete(env)
click to toggle source
# File lib/tumugi/plugin/webhook/logger.rb, line 21 def on_complete(env) status = env[:status] log_response_status(status) { "HTTP #{status}" } log_response(env) end