Skip to content

Commit da01802

Browse files
committed
feat(Alchemy::Logger): Add Error type to message
For warnings and errors we add the Type as prefix, so it easier to visually parse in logs. Signed-off-by: Thomas von Deyen <[email protected]>
1 parent 4116e88 commit da01802

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/alchemy/logger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def self.debug(message)
1313
# Logs a error message to the Rails standard logger
1414
def self.error(message)
1515
Rails.logger.tagged("alchemy") do
16-
Rails.logger.error(message)
16+
Rails.logger.error("ERROR: #{message}")
1717
end
1818
nil
1919
end
@@ -32,7 +32,7 @@ def self.warn(message, caller_string = nil)
3232
Alchemy::Deprecation.warn("Alchemy::Logger.warn second argument is deprecated and will be removed in Alchemy 9.0")
3333
end
3434
Rails.logger.tagged("alchemy") do
35-
Rails.logger.warn(message)
35+
Rails.logger.warn("WARNING: #{message}")
3636
end
3737
nil
3838
end

spec/libraries/logger_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Something
3131
it { is_expected.to be_nil }
3232

3333
it "uses Rails error logger" do
34-
expect(Rails.logger).to receive(:error).with(message)
34+
expect(Rails.logger).to receive(:error).with("ERROR: #{message}")
3535
subject
3636
end
3737

@@ -74,7 +74,7 @@ class Something
7474
it { is_expected.to be_nil }
7575

7676
it "uses Rails warn logger" do
77-
expect(Rails.logger).to receive(:warn).with(message)
77+
expect(Rails.logger).to receive(:warn).with("WARNING: #{message}")
7878
subject
7979
end
8080

0 commit comments

Comments
 (0)