Hans Deragon wrote:
Greetings M. Chu,
The most practical solution is to send running status messages to one stream, as you suggest, though I would send it to stdout, not stderr. In my view, stderr is for errors and diagnostics in the sense of debugging, not for normal operation. A tool that reports the status of its operations should send its output to stdout. Connection errors, timeouts and such abnormal errors should be reported to stderr. Duplicate values, existing values, entry not found and such are normal operational messages and should be sent to stdout.
I made my changes because they were the simplest, fasted solutions which do not modify the current tools default behavior. I also believe that in the context of logging, using one single stream to record all events in chronological order is very practical. Since we disagree on this matter and you are chef architect of OpenLDAP, you decision stands and I respect that. We will leave the tools as is.
You still have several other alternatives to investigate. As Hallvard suggested, simply calling setlinebuf(stdout) in the tools may be sufficient.
Best regards, Hans Deragon
Hallvard Breien Furuseth wrote:
Hans Deragon wrote:
I implemented a simple common option (-K) for the client tools that if enabled, sets the file descriptor used to output errors to stdout instead of the default (and currently used) stderr.
That would be stupid. Error messages belong on stderr, that's why it exists.
This is done because when running a batch of commands with the output sent to a file, logs collected are not shown chronologically because the output is split between stdout and stderr. (...)
There are two obvious fixes: 1) don't send batches of commands that ignore errors, so that the processing immediately stops at the failed entry. 2) change the error message text to include the input line number where it failed.
Also a possibility: don't send running status messages to stdout, send them only to stderr. Technically the only commandline tool that normally produces "output" is ldapsearch. Everything else is "diagnostic" and belongs on stderr anyway.
I suggest instead a -B option to make stdout unbuffered or linebuffered.
stdout is already linebuffered by default when directed to a tty.
-- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/