rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: James Tucker <jftucker@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Rack::CommonLogger does not receive Logger Instance. is this bug?
Date: Thu, 20 May 2010 11:21:11 -0300	[thread overview]
Message-ID: <8C4710BE-8E43-4547-A107-1B538E9B79FD@gmail.com> (raw)
In-Reply-To: <4c699dd9-5da3-45b4-88b1-e1e0001c4a44@y18g2000prn.googlegroups.com>


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.

  reply	other threads:[~2010-05-20 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-05 16:03 Rack::CommonLogger does not receive Logger Instance. is this bug? sanemat
2010-05-20 14:21 ` James Tucker [this message]
2012-11-01 14:55   ` Paul O'Keeffe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8C4710BE-8E43-4547-A107-1B538E9B79FD@gmail.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).