Feature #12224
closedlogger: Allow specifying log level in constructor
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:
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:
This will be effectively same as the original code I indicated above.
I attached a patch for this.
Files
Updated by shevegen (Robert A. Heiler) over 10 years ago
Here is the link to Logger:
It already uses multiple arguments:
So I assume another optional one such as :level would be ok (my personal opinion).
Updated by sonots (Naotoshi Seo) over 10 years ago
- Assignee set to sonots (Naotoshi Seo)
Updated by sonots (Naotoshi Seo) over 10 years ago
- Status changed from Open to Closed
Applied in changeset r54638.
Allow specifying logger parameters in constructor
- lib/logger.rb: Allow specifying logger prameters such as level,
progname, datetime_format, formatter in constructor [Bug #12224]
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Has duplicate Feature #13244: stdlib/Logger: add option: level added