* Rack::CommonLogger does not receive Logger Instance. is this bug? @ 2010-05-05 16:03 sanemat 2010-05-20 14:21 ` James Tucker 0 siblings, 1 reply; 3+ messages in thread From: sanemat @ 2010-05-05 16:03 UTC (permalink / raw) To: Rack Development hi. I'm sanemat. I use rest-client-components and rack-common-logger. It does not work, and I find problem in Rack::CommonLogger. Logger Instance does not have +write+ method. But Rack::CommonLogger's constructer require +write+ method in second parameter. ------ NoMethodError - undefined method `write' for #<Logger:0xb736acec>: /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/commonlogger.rb:31:in `log' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/commonlogger.rb:20:in `call' ------ modify way I think: a. change Logger instance b. change commonlogger or anyway. so i try 'a' way like below, and it works. http://github.com/choonkeat/tweetstreamproxy/commit/ec82b0ac04b4f20ba33bf4f25dfb3f60e122d44c Logger.class_eval { alias :write :"<<" } unless Logger.instance_methods.include? "write" or 'b' way. like this. http://github.com/sanemat/rack/commit/865ab9655aa2aa226a9d21b8dfd39e001c9bdeb0 change method again from +write+ to +<<+. this changed one years ago. http://github.com/rack/rack/commit/761c6246e18b92752353c0f412976ded4a417dc5 which is better? I confuse this. i may be wrong but few people use Logger? thank you. rack 1.1.0 $ ruby -v ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux] $ uname -a Linux fri 2.6.32.10-90.fc12.i686 #1 SMP Tue Mar 23 10:21:29 UTC 2010 i686 i686 i386 GNU/Linux -- sanemat ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Rack::CommonLogger does not receive Logger Instance. is this bug? 2010-05-05 16:03 Rack::CommonLogger does not receive Logger Instance. is this bug? sanemat @ 2010-05-20 14:21 ` James Tucker 2012-11-01 14:55 ` Paul O'Keeffe 0 siblings, 1 reply; 3+ messages in thread From: James Tucker @ 2010-05-20 14:21 UTC (permalink / raw) To: rack-devel On 5 May 2010, at 13:03, sanemat wrote: > Logger Instance does not have +write+ method. > But Rack::CommonLogger's constructer require +write+ method in second > parameter. class MyLogger << Logger alias write << end use Rack::CommonLogger, MyLogger.new > modify way I think: > a. change Logger instance > b. change commonlogger > > or anyway. > > so i try 'a' way like below, and it works. > > http://github.com/choonkeat/tweetstreamproxy/commit/ec82b0ac04b4f20ba33bf4f25dfb3f60e122d44c > Logger.class_eval { alias :write :"<<" } unless > Logger.instance_methods.include? "write" This is horrible. I do wish people would subclass first rather than monkey patch first (glaring evil stares at rails here too as there's no need to monkey patch Logger, like, ever). > or 'b' way. like this. > http://github.com/sanemat/rack/commit/865ab9655aa2aa226a9d21b8dfd39e001c9bdeb0 > change method again from +write+ to +<<+. this changed one years ago. > http://github.com/rack/rack/commit/761c6246e18b92752353c0f412976ded4a417dc5 I see the implementation used to be compatible with Logger, that change did indeed break it. It uses write to expect something IO-ish, not something Logger-ish, but I think it would be a valid change to use << instead, however, I cannot remember if we specify this as a requirement for env['rack.errors']. Certainly we should decide one way, however, I have no real problem with the way it presently is, the implementation being simpler than it used to be. > which is better? > I confuse this. > i may be wrong but few people use Logger? Generally, no, people use env['rack.errors'], which is IO-ish. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Rack::CommonLogger does not receive Logger Instance. is this bug? 2010-05-20 14:21 ` James Tucker @ 2012-11-01 14:55 ` Paul O'Keeffe 0 siblings, 0 replies; 3+ messages in thread From: Paul O'Keeffe @ 2012-11-01 14:55 UTC (permalink / raw) To: rack-devel [-- Attachment #1: Type: text/plain, Size: 257 bytes --] > > Calling that second parameter to the initialize method 'logger' tripped me > up too. Having not seen earlier implementations, I assumed this to be a > ::Logger rather than an IO stream.Perhaps the parameter should be renamed > to 'io' or 'stream'? [-- Attachment #2: Type: text/html, Size: 370 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-01 15:10 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-05-05 16:03 Rack::CommonLogger does not receive Logger Instance. is this bug? sanemat 2010-05-20 14:21 ` James Tucker 2012-11-01 14:55 ` Paul O'Keeffe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).