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

Fix deprecation warning on Ruby 2.7 #105

Merged
merged 1 commit into from
May 2, 2020
Merged

Fix deprecation warning on Ruby 2.7 #105

merged 1 commit into from
May 2, 2020

Conversation

haines
Copy link
Contributor

@haines haines commented May 1, 2020

The Logger constructor takes keyword arguments, but the Ougai::Logger subclass only takes positional arguments. This relies on the now-deprecated behaviour that if the last argument to a method is a hash it can be used as keyword arguments, so it generates a warning on Ruby 2.7:

~/lib/ougai/logger.rb:15: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
~/.rubies/ruby-2.7.1/lib/ruby/2.7.0/logger.rb:379: warning: The called method `initialize' is defined here

This PR fixes the deprecation warning by specifying that the constructor can take both positional and keyword arguments, and passing all arguments through to the superclass constructor.

@@ -11,8 +11,8 @@ class Logger < ::Logger

attr_accessor :default_message, :exc_key

def initialize(*args)
super(*args)
def initialize(*, **)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo) The arguments are composed of optional ones and keyword ones. https://github.com/ruby/logger/blob/master/lib/logger.rb#L380

@tilfin
Copy link
Owner

tilfin commented May 2, 2020

@haines Thank you! 👍

@tilfin tilfin merged commit f18ba91 into tilfin:master May 2, 2020
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 this pull request may close these issues.

2 participants