Skip to content
Snippets Groups Projects
Commit ce167089 authored by Jorn van de Beek's avatar Jorn van de Beek
Browse files

Add timezone to log lines

parent 8c67cd7b
Branches
Tags
1 merge request!45Timezone toevoegen aan Roqua logging railtie regels
Pipeline #96149 passed
......@@ -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'
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment