Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<empty error message> when using a logger with a block #1251

Open
meloluiza opened this issue Jun 18, 2023 · 1 comment
Open

<empty error message> when using a logger with a block #1251

meloluiza opened this issue Jun 18, 2023 · 1 comment

Comments

@meloluiza
Copy link

meloluiza commented Jun 18, 2023

Hello,

I have been experiencing numerous RuntimeError: <empty error message> errors on Airbrake. Upon investigation, I discovered that these errors occur when using logger with a block.

For instance, Rails.logger.warn("Error") works as intended, and I get RuntimeError: Error. However, when using Rails.logger.warn { "Error" }, I get the RuntimeError: <empty error message>.

Upon reviewing the code, I noticed that the warn method, - as well as the other log levels - receives the block as a parameter but does not pass it forward neither evaluates it to get the message. In scenarios involving blocks, the progname is nil, therefore an empty error message.

It is highly recommended to use blocks when logging for performance reasons, as stated in the Rails Debugging Guide.

I change all my loggers to not use a block for now, but unfortunately, most of the errors are related to ActiveJob::LogSubscriber, and there isn't much I can do about it.

Is there a possibility of addressing this issue and fixing the error messages?

Gemfile.lock

airbrake (13.0.3)
  airbrake-ruby (~> 6.0)
airbrake-ruby (6.2.1)
@flugsio
Copy link

flugsio commented Jun 21, 2023

Steps to reproduce, using rails 7.0.5 and airbrake 13.0.3, airbrake-ruby 6.2.1

rails new test123
cd test123
echo 'gem "airbrake"' >> Gemfile
bundle
sed -i '/Rails.logger = /s/# //' config/initializers/airbrake.rb
export AIRBRAKE_PROJECT_ID=1
export AIRBRAKE_PROJECT_KEY=abc
echo 'Rails.logger.error { "test2" }' | bin/rails c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants