Project

General

Profile

Actions

Feature #12224

closed

logger: Allow specifying log level in constructor

Added by rhenium (Kazuki Yamaguchi) about 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:74614]

Description

When I use Logger class, I very often (or maybe always) set minimal log level together. Since method chaining can't be used for setters, we have to split it into two statements:

logger = Logger.new($stdout)
logger.level = :info

Imagine if the logger was much longer name, such as ActiveRecord::Base.logger. I personally don't want to repeat it.
I found a number of samples on GitHub (they would countain copy-and-pastes though) [1].

So I propose adding a new keyword argument level to Logger.new:

logger = Logger.new($stdout, level: :info)

This will be effectively same as the original code I indicated above.

I attached a patch for this.

[1] https://github.com/search?utf8=%E2%9C%93&q=%22%3D+Logger.new%22+%22level+%3D%22+language%3ARuby&type=Code&ref=searchresults


Files


Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Feature #13244: stdlib/Logger: add option: levelRejectedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0