librelist archives

« back to archive

puts vs logger

puts vs logger

From:
Ben VandenBos
Date:
2010-07-21 @ 21:14
So, what's the consensus on using puts statements vs a logger?

I've gotten 2 pull requests in the past week for resque-scheduler to 
switch to a logger.  I want to stay consistent w/ resque's logging which 
uses puts.  Also, I like to let my runit/supervise handle rolling, 
pruning, etc rather than the app so a logger would just be more code to 
maintain.  But if the pull requests keep coming, I figure some people must
really want it and it's worth discussing.

I guess the argument for a logger is that you can default it to stdout and
it would behave the same as it currently does.  It adds only a little 
complexity, works the same out of the box, and allows for others to use 
their own output if they so desire.

Chris - I'm guessing you're in the keep-it-simple-just-use-puts camp as well?

thanks!

ben

Re: [resque] puts vs logger

From:
David Balatero
Date:
2010-07-21 @ 21:20
I'm one of the people that sent you a pull request. I can see it either 
way, honestly.

However, require 'logger' + logger.info(str) isn't any more complex than 
puts(str). Also, it lets you control debug statements vs info statements 
by using #debug and #info.

I noticed in the codebase you have a #log and #log! method -- one for info
and one for debug. Isn't that reimplementing the same complexity you want 
to avoid from the Logger package?

David

On Jul 21, 2010, at 2:14 PM, Ben VandenBos <bvandenbos@gmail.com> wrote:

> So, what's the consensus on using puts statements vs a logger?
> 
> I've gotten 2 pull requests in the past week for resque-scheduler to 
switch to a logger.  I want to stay consistent w/ resque's logging which 
uses puts.  Also, I like to let my runit/supervise handle rolling, 
pruning, etc rather than the app so a logger would just be more code to 
maintain.  But if the pull requests keep coming, I figure some people must
really want it and it's worth discussing.
> 
> I guess the argument for a logger is that you can default it to stdout 
and it would behave the same as it currently does.  It adds only a little 
complexity, works the same out of the box, and allows for others to use 
their own output if they so desire.
> 
> Chris - I'm guessing you're in the keep-it-simple-just-use-puts camp as well?
> 
> thanks!
> 
> ben
> 

Re: [resque] puts vs logger

From:
Chris Wanstrath
Date:
2010-07-21 @ 21:39
On Jul 21, 2010, at 2:20 PM, David Balatero <dbalatero@gmail.com> wrote:

> I'm one of the people that sent you a pull request. I can see it either 
way, honestly.
> 
> However, require 'logger' + logger.info(str) isn't any more complex than
puts(str). Also, it lets you control debug statements vs info statements 
by using #debug and #info.
> 
> I noticed in the codebase you have a #log and #log! method -- one for 
info and one for debug. Isn't that reimplementing the same complexity you 
want to avoid from the Logger package?

Not exactly.

The Logger class, because you control it by instantiating an object with 
different options, is great for libraries and APIs - especially those 
living within a larger system, exposed only to other code.

Resque is a system itself, and you don't launch or control workers 
(generally) with a machine API. Instead you do it from the command line, 
in which case it's easier to just redirect STDOUT than add a bunch of 

In other words:

Logger is probably most useful when you can't redirect standard out, or  
different subsystems are writing to the same fd. Resque doesn't seem to 
need that yet.

> 
> David
> 
> On Jul 21, 2010, at 2:14 PM, Ben VandenBos <bvandenbos@gmail.com> wrote:
> 
>> So, what's the consensus on using puts statements vs a logger?
>> 
>> I've gotten 2 pull requests in the past week for resque-scheduler to 
switch to a logger.  I want to stay consistent w/ resque's logging which 
uses puts.  Also, I like to let my runit/supervise handle rolling, 
pruning, etc rather than the app so a logger would just be more code to 
maintain.  But if the pull requests keep coming, I figure some people must
really want it and it's worth discussing.
>> 
>> I guess the argument for a logger is that you can default it to stdout 
and it would behave the same as it currently does.  It adds only a little 
complexity, works the same out of the box, and allows for others to use 
their own output if they so desire.
>> 
>> Chris - I'm guessing you're in the keep-it-simple-just-use-puts camp as well?
>> 
>> thanks!
>> 
>> ben
>> 

Re: [resque] puts vs logger

From:
Chris Wanstrath
Date:
2010-07-21 @ 21:31
On Jul 21, 2010, at 2:14 PM, Ben VandenBos <bvandenbos@gmail.com> wrote:

> So, what's the consensus on using puts statements vs a logger?
> 
> I guess the argument for a logger is that you can default it to stdout 
and it would behave the same as it currently does.  It adds only a little 
complexity, works the same out of the box, and allows for others to use 
their own output if they so desire.

I'm not sold on loggers for basic systems like Resque. In Unix you can 
easily redirect STDOUT to a log file, which is what we do. No extra code 
required.

Re: [resque] puts vs logger

From:
Ben VandenBos
Date:
2010-07-21 @ 21:40
David - good point about log methods, but it's the dependency on Logger 
that I'm avoiding.  That, and signing up the process for supporting more 
than it really needs to.




On Jul 21, 2010, at 2:31 PM, Chris Wanstrath wrote:

> On Jul 21, 2010, at 2:14 PM, Ben VandenBos <bvandenbos@gmail.com> wrote:
> 
>> So, what's the consensus on using puts statements vs a logger?
>> 
>> I guess the argument for a logger is that you can default it to stdout 
and it would behave the same as it currently does.  It adds only a little 
complexity, works the same out of the box, and allows for others to use 
their own output if they so desire.
> 
> I'm not sold on loggers for basic systems like Resque. In Unix you can 
easily redirect STDOUT to a log file, which is what we do. No extra code 
required.

puts vs logger

From:
Ashley Martens
Date:
2010-07-23 @ 01:06
Sorry I have not been following this thread but it has been brought to my
attention and I'll throw in my $0.02.

Redirect is "unix" way for command line tools not daemons. Daemons log,
usually to syslog.

That said the default logger can output to STDOUT and mirror puts, however,
it configurable. If you want output to go to a file you can have that
(without modifying the source code). If you want the output to go to STDOUT
you go it. You want to output more, no problem, less, no problem.
Flexibility without rewriting. Can we have that?