Skip to content

Commit

Permalink
Use same format as json logger for logfmt logger
Browse files Browse the repository at this point in the history
  • Loading branch information
treacher authored and PatrickTulskie committed Aug 1, 2023
1 parent 748de7c commit 1efc9c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/resque/scheduler/logger_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def json_formatter

def logfmt_formatter
proc do |severity, datetime, progname, msg|
"Timestamp=\"#{datetime.iso8601}\" " \
"SeverityText=\"#{severity}\" " \
"InstrumentationScope=\"#{progname}\" " \
"Body=\"#{msg}\"\n"
"timestamp=\"#{datetime.iso8601}\" " \
"level=\"#{severity}\" " \
"progname=\"#{progname}\" " \
"msg=\"#{msg}\"\n"
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions test/scheduler_setup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def wipe
Resque::Scheduler.log! 'another thing'

expected_output = "resque-scheduler: [INFO] #{DateTime.now.iso8601}: another thing\n"

assert_equal($stdout.string, expected_output)
end
end
Expand All @@ -170,8 +171,8 @@ def wipe
Timecop.freeze do
Resque::Scheduler.log! 'another thing'

expected_output = "Timestamp=\"#{DateTime.now.iso8601}\" SeverityText=\"INFO\" " \
"InstrumentationScope=\"resque-scheduler\" Body=\"another thing\"\n"
expected_output = "timestamp=\"#{DateTime.now.iso8601}\" level=\"INFO\" " \
"progname=\"resque-scheduler\" msg=\"another thing\"\n"

assert_equal($stdout.string, expected_output)
end
Expand Down

0 comments on commit 1efc9c1

Please sign in to comment.