diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.cc | 11 | ||||
-rw-r--r-- | src/libutil/util.hh | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 6d96310da..4460d95b8 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -437,7 +437,7 @@ void printMsg_(Verbosity level, const format & f) else if (logType == ltEscapes && level != lvlInfo) prefix = "\033[" + escVerbosity(level) + "s"; string s = (format("%1%%2%\n") % prefix % f.str()).str(); - writeFull(STDERR_FILENO, (const unsigned char *) s.c_str(), s.size()); + writeToStderr((const unsigned char *) s.c_str(), s.size()); } @@ -450,6 +450,15 @@ void warnOnce(bool & haveWarned, const format & f) } +static void defaultWriteToStderr(const unsigned char * buf, size_t count) +{ + writeFull(STDERR_FILENO, buf, count); +} + + +void (*writeToStderr) (const unsigned char * buf, size_t count) = defaultWriteToStderr; + + void readFull(int fd, unsigned char * buf, size_t count) { while (count) { diff --git a/src/libutil/util.hh b/src/libutil/util.hh index d49067dfe..0d39ffee9 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -131,6 +131,8 @@ void printMsg_(Verbosity level, const format & f); void warnOnce(bool & haveWarned, const format & f); +extern void (*writeToStderr) (const unsigned char * buf, size_t count); + /* Wrappers arount read()/write() that read/write exactly the requested number of bytes. */ |