Puts & logger ... flush immediately

newbie here …

I am tracing logic putting puts and logger.info calls in my code.

I think Rails is buffering output so that I can’t see what happens
until I close out webrick.

How do I tell Rails (or whatever) that output is not to be buffered?

Ralph S. wrote:

newbie here …

I am tracing logic putting puts and logger.info calls in my code.

I think Rails is buffering output so that I can’t see what happens
until I close out webrick.

But you are probably wrong. If you watch the log scroll by, you will
generally see puts and logger output immediately.

How do I tell Rails (or whatever) that output is not to be buffered?

You should not need to.

Also, get familiar with ruby-debug and test-first development. These
two things will drastically reduce your need for logging.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Marnen Laibow-Koser wrote:

Ralph S. wrote:

newbie here …

I am tracing logic putting puts and logger.info calls in my code.

I think Rails is buffering output so that I can’t see what happens
until I close out webrick.

But you are probably wrong. If you watch the log scroll by, you will
generally see puts and logger output immediately.

How do I tell Rails (or whatever) that output is not to be buffered?

You should not need to.

Also, get familiar with ruby-debug and test-first development. These
two things will drastically reduce your need for logging.

Dude, don’t be such a dick. Logging doesn’t necessarily have to do with
debugging or test-first development.

Best,
Michael G.

Michael G. wrote:

Marnen Laibow-Koser wrote:

Ralph S. wrote:

newbie here …

I am tracing logic putting puts and logger.info calls in my code.

I think Rails is buffering output so that I can’t see what happens
until I close out webrick.

But you are probably wrong. If you watch the log scroll by, you will
generally see puts and logger output immediately.

How do I tell Rails (or whatever) that output is not to be buffered?

You should not need to.

Also, get familiar with ruby-debug and test-first development. These
two things will drastically reduce your need for logging.

Dude, don’t be such a dick. Logging doesn’t necessarily have to do with
debugging or test-first development.

I’m aware of that, and even if I were not, that’s no reason for
name-calling. You owe me an apology.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Best,
Michael G.

On Mon, Jan 18, 2010 at 8:04 AM, Michael G. [email protected]
wrote:

generally see puts and logger output immediately.
Dude, don’t be such a dick. Â Logging doesn’t necessarily have to do with
debugging or test-first development.

Actually they do. Logging is a form of debugging, and often is
suggested as the first form before jumping into a debugger and walking
through code.

As you get better at test driven development, your need for logging
and debugging go down.

Of course there is logging that you do just to monitor the health of
your application, but since the OP said, “I am tracing logic putting
puts and logger.info calls in my code.” it seems he is using logging
and puts to debug his application.

That said, if you are on a *NIX machine, including Mac, it’s not Rails
or Ruby that is buffering but the OS. Not sure if there is anything
you can do about that. Coming from the Java world, I used to always
put my debug output to standard error since that was not buffered and
you saw it in real time.

Curtis C.
[email protected]
home:http://curtiscooley.com
blog:http://ponderingobjectorienteddesign.blogspot.com

Leadership is a potent combination of strategy and character. But if
you must be without one, be without the strategy.
– H. Norman Schwarzkopf

Aldric G. wrote:

Curtis C. wrote:

On Mon, Jan 18, 2010 at 8:04 AM, Michael G. [email protected]
wrote:

generally see puts and logger output immediately.
Dude, don’t be such a dick. Â Logging doesn’t necessarily have to do with
debugging or test-first development.

Actually they do. Logging is a form of debugging, and often is
suggested as the first form before jumping into a debugger and walking
through code.

Unless of course you have specific NEEDS for logging, like HIPAA
regulations. Sometimes it doesn’t matter how clever you are, or how well
your tests are built. You simply need logs.

Although for that sort of logging, the Rails logger probably wouldn’t be
much good.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Jan 18, 4:23Â pm, Curtis C. [email protected] wrote:

That said, if you are on a *NIX machine, including Mac, it’s not Rails
or Ruby that is buffering but the OS. Not sure if there is anything
you can do about that. Coming from the Java world, I used to always
put my debug output to standard error since that was not buffered and
you saw it in real time.

the default logger is buffered (if you have a look it’s an instance of
ActiveSupport::BufferedLogger). It should be flushed on at least a
once-per-action basis.

Fred

Curtis C. wrote:

On Mon, Jan 18, 2010 at 8:04 AM, Michael G. [email protected]
wrote:

generally see puts and logger output immediately.
Dude, don’t be such a dick. Â Logging doesn’t necessarily have to do with
debugging or test-first development.

Actually they do. Logging is a form of debugging, and often is
suggested as the first form before jumping into a debugger and walking
through code.

Unless of course you have specific NEEDS for logging, like HIPAA
regulations. Sometimes it doesn’t matter how clever you are, or how well
your tests are built. You simply need logs.