Issue #13244 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

It has been added since 2.4.

----------------------------------------
Feature #13244: stdlib/Logger: add option: level
https://bugs.ruby-lang.org/issues/13244#change-63133

* Author: Eike Dierks
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I'd like to suggest
to enhance the interface of stdlib/logger

The #new method should allow for an option to set the log level:

~~~ruby
Logger#new(logdev, level:'WARN')
~~~

As with ruby 2.4 there is no provision to set the log level from `#new `
But instead the level attribute needs to be set on the Logger object.

This leads to code like:

~~~ruby
def logger
  unless @logger
    @logger ||= Logger.new(STDERR)
    logger.level = 'WARN'
  end
  return logger
end
~~~

while by it would be much more expressive to write:

~~~ruby
def logger
  @logger ||= Logger.new(STDERR, level:'WARN')
end
~~~

I believe this would not break any previous usage of the api.












-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>