diff --git a/lib/roqua/logging/roqua_logging_railtie.rb b/lib/roqua/logging/roqua_logging_railtie.rb index 6881646da9d31f823689525ec6488851ad5e80d4..62b84c519410fafb64e2f11e1f9cc65e66a782cc 100644 --- a/lib/roqua/logging/roqua_logging_railtie.rb +++ b/lib/roqua/logging/roqua_logging_railtie.rb @@ -7,6 +7,8 @@ class RoquaLoggingRailtie < Rails::Railtie def configure Roqua.logger = ActiveSupport::Logger.new(output_stream).tap do |logger| logger.formatter = Logger::Formatter.new + # Set the datetime_format to include timezone and use milliseconds instead of microseconds + logger.formatter.datetime_format = '%Y-%m-%dT%H:%M:%S.%L%z ' end require 'roqua/support/request_logger' diff --git a/spec/roqua/logging/roqua_logging_railtie_spec.rb b/spec/roqua/logging/roqua_logging_railtie_spec.rb index eaa9e43a88cc353204e51071e76c262f1f1ebd7a..5f12ee2b180e60fad6d2af6e752332e4efb76ff6 100644 --- a/spec/roqua/logging/roqua_logging_railtie_spec.rb +++ b/spec/roqua/logging/roqua_logging_railtie_spec.rb @@ -27,6 +27,12 @@ Rspec.describe RoquaLoggingRailtie do ActiveSupport::Logger.logger_outputs_to?(Roqua.logger.logger, STDOUT) ).to be_truthy end + + it 'logs using a datetimeformat including timezone' do + time = Time.zone.local(2021,10,10,16,13) + got = Roqua.logger.logger.formatter.call 'INFO', time, 'progname', '{}' + expect(got).to match(/I, \[2021-10-10T16:13:00.000\+0000 #\d+] INFO -- progname: {}/) + end end context 'when RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER is blank' do