From c52ade2f3a978fc427c2150381dec4650ff4bc0e Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Mon, 1 Jul 2019 09:42:15 +1000 Subject: [PATCH] feat(webhooks): simplify request logger format --- lib/pact_broker/webhooks/webhook_request_logger.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/pact_broker/webhooks/webhook_request_logger.rb b/lib/pact_broker/webhooks/webhook_request_logger.rb index 21dc8c169..097a94ec0 100644 --- a/lib/pact_broker/webhooks/webhook_request_logger.rb +++ b/lib/pact_broker/webhooks/webhook_request_logger.rb @@ -10,9 +10,22 @@ class WebhookRequestLogger attr_reader :execution_logger, :options + class Formatter < Logger::Formatter + Format = "[%s] %s: %s\n".freeze + + def call(severity, time, progname, msg) + Format % [format_datetime(time), severity, msg2str(msg)] + end + + def format_datetime(time) + time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%SZ".freeze) + end + end + def initialize(options) @log_stream = StringIO.new @execution_logger = Logger.new(log_stream) + @execution_logger.formatter = Formatter.new @options = options end