From ff84c326b18b3648fa07abb8cd73dc57005a8bb0 Mon Sep 17 00:00:00 2001 From: Gavin Mogan Date: Tue, 3 Sep 2019 16:46:27 -0700 Subject: [PATCH] Logger can take in exceptions according to documentation so stringify first Docs: https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html\#method-i-add-label-Args --- lib/raven/breadcrumbs/logger.rb | 2 +- spec/raven/logger_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/raven/breadcrumbs/logger.rb b/lib/raven/breadcrumbs/logger.rb index 2c3149e7b..a5f5cd935 100644 --- a/lib/raven/breadcrumbs/logger.rb +++ b/lib/raven/breadcrumbs/logger.rb @@ -36,7 +36,7 @@ def add_breadcrumb(severity, message = nil, progname = nil) # some loggers will add leading/trailing space as they (incorrectly, mind you) # think of logging as a shortcut to std{out,err} - message = message.strip + message = message.to_s.strip last_crumb = Raven.breadcrumbs.peek # try to avoid dupes from logger broadcasts diff --git a/spec/raven/logger_spec.rb b/spec/raven/logger_spec.rb index cc24ee08d..638fff8a9 100644 --- a/spec/raven/logger_spec.rb +++ b/spec/raven/logger_spec.rb @@ -9,4 +9,13 @@ expect(stringio.string).to end_with("FATAL -- sentry: ** [Raven] Oh noes!\n") end + + it "should allow exceptions to be logged" do + stringio = StringIO.new + log = Raven::Logger.new(stringio) + + log.fatal(Exception.new("Oh exceptions")) + + expect(stringio.string).to end_with("FATAL -- sentry: ** [Raven] Oh exceptions\n") + end end