puts & logger ... flush immediately

Marnen Laibow-Koser wrote:

Ralph Shnelvar 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 Guterl

Michael Guterl wrote:

Marnen Laibow-Koser wrote:

Ralph Shnelvar 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,

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 Cooley wrote:

Aldric Giacomoni wrote:

Curtis Cooley 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,

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