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

Ruby 2.7: Logger Warnings #104

Closed
jessedoyle opened this issue Jun 28, 2021 · 1 comment · Fixed by #105
Closed

Ruby 2.7: Logger Warnings #104

jessedoyle opened this issue Jun 28, 2021 · 1 comment · Fixed by #105

Comments

@jessedoyle
Copy link
Contributor

Hi There,

Thanks again for making a great library!

I recently wrote the following code in my app running ruby 2.7.1:

require 'logger'
logger = Logger.new(STDOUT, level: Logger::INFO)

I noticed the following warning that was emitted by the interpreter:

/Users/me/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/lamby-3.0.2/lib/lamby/logger.rb:12: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/me/.rbenv/versions/2.7.1/lib/ruby/2.7.0/logger.rb:379: warning: The called method `initialize' is defined here

It looks like Lamby is overwriting the constructor for the Logger class in the standard library - is this necessary?

An easy fix may be to use the double-splat (**) operator in the definition of the override. If you want, I can submit a PR to make this change?

Thanks!

@jessedoyle
Copy link
Contributor Author

jessedoyle commented Jun 29, 2021

I just wanted to add some further context to the conversation. Here's a link to the Logger constructor in the standard library.

jessedoyle added a commit to jessedoyle/lamby that referenced this issue Jun 30, 2021
* resolves rails-lambda#104

Lamby overrides the default implementation of `Logger` in the
standard library and provides a constructor to redirect all
log output to STDOUT.

When run in Ruby 2.7, the constructor override causes the
interpreter to emit the following warning:

```
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
```

A simple fix for this warning is to proxy the keyword arguments
in the override to the original defnintion using the double-splat
(`**`) operator.
metaskills added a commit that referenced this issue Jun 30, 2021
fix(ruby-27): Ruby 2.7 Warnings | Logger
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

Successfully merging a pull request may close this issue.

1 participant