Project

General

Profile

Feature #13244

stdlib/Logger: add option: level

Added by eike.rb (Eike Dierks) 7 months ago. Updated 7 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:79709]

Description

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:

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:

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:

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

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


Related issues

Is duplicate of Ruby trunk - Feature #12224: logger: Allow specifying log level in constructorClosed

History

#1 Updated by nobu (Nobuyoshi Nakada) 7 months ago

  • Is duplicate of Feature #12224: logger: Allow specifying log level in constructor added

#2 [ruby-core:79711] Updated by nobu (Nobuyoshi Nakada) 7 months ago

  • Status changed from Open to Rejected
  • Description updated (diff)

It has been added since 2.4.

Also available in: Atom PDF