From: <sv...@ww...> - 2004-06-14 08:37:45
|
Author: mkrose Date: 2004-06-14 01:37:38 -0700 (Mon, 14 Jun 2004) New Revision: 1044 Modified: trunk/CSP/SimData/Include/SimData/LogStream.h trunk/CSP/SimData/Source/LogStream.cpp Log: Remove sync() when redirecting log output to prevent segfaults; slight tweak of logic for closing logstreams, and minor formating fixups Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1044 Modified: trunk/CSP/SimData/Include/SimData/LogStream.h =================================================================== --- trunk/CSP/SimData/Include/SimData/LogStream.h 2004-06-14 07:49:33 UTC (rev 1043) +++ trunk/CSP/SimData/Include/SimData/LogStream.h 2004-06-14 08:37:38 UTC (rev 1044) @@ -41,6 +41,7 @@ #include <iostream> #include <fstream> #include <string> +#include <cassert> #include <SimData/Namespace.h> #include <SimData/Export.h> @@ -218,6 +219,7 @@ } void _close() { + lbuf.set_sb(NULL); if (m_out != NULL) { m_out->close(); delete m_out; @@ -231,7 +233,7 @@ */ void setOutput(std::ostream& out_) { _close(); - lbuf.set_sb(out_.rdbuf() ); + lbuf.set_sb(out_.rdbuf()); } /** Set the output stream @@ -241,7 +243,8 @@ void setOutput(std::string const &fn) { _close(); m_out = new std::ofstream(fn.c_str()); - lbuf.set_sb( m_out->rdbuf() ); + assert(m_out != NULL); + lbuf.set_sb(m_out->rdbuf()); } /** Set the global log class and priority level. Modified: trunk/CSP/SimData/Source/LogStream.cpp =================================================================== --- trunk/CSP/SimData/Source/LogStream.cpp 2004-06-14 07:49:33 UTC (rev 1043) +++ trunk/CSP/SimData/Source/LogStream.cpp 2004-06-14 08:37:38 UTC (rev 1044) @@ -42,12 +42,12 @@ logbuf::~logbuf() { - if (sbuf) sync(); + //if (sbuf) sync(); // logs are already flushed by endl } void logbuf::set_sb(std::streambuf* sb) { - if (sbuf) sync(); + //if (sbuf) sync(); // enabling this causes segfaults when redirecting output sbuf = sb; } |