From 10753b34f309db0fbcc484716bafff09faada6fd Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 9 Apr 2012 06:22:16 +0000 Subject: Cleanup Scribe log output and add ability to log to a firehose Unix fifo pipe. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1311137 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/patches/scribe.patch | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 sca-cpp/trunk/patches/scribe.patch (limited to 'sca-cpp/trunk/patches/scribe.patch') diff --git a/sca-cpp/trunk/patches/scribe.patch b/sca-cpp/trunk/patches/scribe.patch new file mode 100644 index 0000000000..6340c4634d --- /dev/null +++ b/sca-cpp/trunk/patches/scribe.patch @@ -0,0 +1,50 @@ +--- src/common.h ++++ src/common.h +@@ -42,6 +42,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include + +--- src/file.cpp ++++ src/file.cpp +@@ -74,9 +74,21 @@ bool StdFile::openRead() { + } + + bool StdFile::openWrite() { ++ // if file is a fifo, temporarily open it for read ++ int fd = -1; ++ struct stat st; ++ int s = stat(filename.c_str(), &st); ++ if (s != -1 && S_ISFIFO(st.st_mode)) ++ fd = ::open(filename.c_str(), O_RDONLY | O_NONBLOCK); ++ + // open file for write in append mode + ios_base::openmode mode = fstream::out | fstream::app; +- return open(mode); ++ bool r = open(mode); ++ ++ // close fifo ++ if (fd != -1) ++ ::close(fd); ++ return r; + } + + bool StdFile::openTruncate() { + +--- src/scribe_server.cpp ++++ src/scribe_server.cpp +@@ -55,6 +55,8 @@ int main(int argc, char **argv) { + if (-1 == setrlimit(RLIMIT_NOFILE, &r_fd)) { + LOG_OPER("setrlimit error (setting max fd size)"); + } ++ ++ signal(SIGPIPE, SIG_IGN); + + int next_option; + const char* const short_options = "hp:c:"; + -- cgit v1.2.3