From: sonots@... Date: 2016-04-10T14:08:03+00:00 Subject: [ruby-core:74868] [Ruby trunk Feature#12224] logger: Allow specifying log level in constructor Issue #12224 has been updated by Naotoshi Seo. Assignee set to Naotoshi Seo ---------------------------------------- Feature #12224: logger: Allow specifying log level in constructor https://bugs.ruby-lang.org/issues/12224#change-57996 * Author: Kazuki Yamaguchi * Status: Open * Priority: Normal * Assignee: Naotoshi Seo ---------------------------------------- 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: ~~~ruby 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: ~~~ruby 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-------------------------------- 0001-lib-logger.rb-allow-specifying-log-level-via-Logger..patch (2.25 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: