aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergely Risko <gergely+context@risko.hu>2009-09-04 10:41:32 +0300
committerGergely Risko <gergely+context@risko.hu>2009-09-04 10:41:32 +0300
commitbb344b10d80e94d8c3ba3d33f5789019884162f6 (patch)
tree46c5f113e6e24e79877e7be2edd1114adb134249
parentc0c009d8d7d9751e6219756db3a4f0dac93861ac (diff)
Logging bug fix, set stderr to always block.
-rw-r--r--common/logging.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/logging.cpp b/common/logging.cpp
index 5f615647..de0ac527 100644
--- a/common/logging.cpp
+++ b/common/logging.cpp
@@ -22,6 +22,7 @@
#include "logging.h"
#include <stdio.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <QDateTime>
#include <QFile>
@@ -405,6 +406,12 @@ ContextRealLogger& ContextRealLogger::operator<< (const ContextFeature &f)
ContextRealLogger::~ContextRealLogger()
{
if (shouldPrint()) {
+ // The Trolls set STDERR to O_NONBLOCK, but ignores the EAGAIN
+ // from write, so if your machine is heavily loaded and the
+ // terminal can't keep up with our log messages you start to
+ // lose them. Hack: just set STDERR to block before every
+ // debug message.
+ fcntl(STDERR_FILENO, F_SETFL, O_WRONLY);
appendFeatures();
QTextStream::operator<<('\n');
QTextStream(stderr) << data;