logger: Allow specifying log level in constructor
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) .
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.
Updated by shevegen (Robert A. Heiler) over 4 years ago
Here is the link to Logger:
It already uses multiple arguments:
new(logdev, shift_age = 7, shift_size = 1048576) new(logdev, shift_age = 'weekly')
So I assume another optional one such as :level would be ok (my personal opinion).