diff options
author | kobica <kobica@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-11-11 15:33:12 +0000 |
---|---|---|
committer | kobica <kobica@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-11-11 15:33:12 +0000 |
commit | 1cfeb884af53feca533290609281350aeb8a2d95 (patch) | |
tree | 3ec412ef4601f7e151fb537b037c883ab104e48b | |
parent | aa055a6410bc41c0344e516fa141347182db9419 (diff) | |
download | ATCD-1cfeb884af53feca533290609281350aeb8a2d95.tar.gz |
ChangeLogTag:Thu Nov 11 17:27:24 2004 Kobi Cohen-Arazi <kobi.cohenarazi@gmail.com>
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ace/Logging_Strategy.cpp | 41 |
2 files changed, 34 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog index e0c21e1caa0..8c5f7c60b45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Nov 11 17:27:24 2004 Kobi Cohen-Arazi <kobi.cohenarazi@gmail.com> + + * ace/Logging_Strategy.cpp: + Fixed handle_timeout conditional test to check the max_size against the size of the + file and not the value of a pointer. + Fix init to handle re-init correctly. When wipeout_logfile_ is true, than + close the file and reopen it truncated, when wipeout_logfile_ is false, don't reopen the + file unless its not open already. + Thu Nov 11 08:34:12 UTC 2004 Johnny Willemsen <jwillemsen@remedy.nl> * bin/msvc_static_order.lst: diff --git a/ace/Logging_Strategy.cpp b/ace/Logging_Strategy.cpp index d268d0cadc1..2191f0309eb 100644 --- a/ace/Logging_Strategy.cpp +++ b/ace/Logging_Strategy.cpp @@ -305,35 +305,44 @@ ACE_Logging_Strategy::init (int argc, ACE_TCHAR *argv[]) ACE_Log_Msg::OSTREAM)) { #if defined (ACE_LACKS_IOSTREAM_TOTALLY) - // check if we already have an opened one. - FILE *output_file = 0; - if (this->log_msg_->msg_ostream () - && ACE_OS::fclose (this->log_msg_->msg_ostream ()) == -1) - return -1; // failed to close the file - + FILE *output_file = this->log_msg_->msg_ostream (); if (wipeout_logfile_) + { + // close and re-open a stream if such exits + if (output_file && + ACE_OS::fclose (output_file) == -1) + return -1; output_file = ACE_OS::fopen (this->filename_, ACE_LIB_TEXT ("wt")); + } else - output_file = ACE_OS::fopen (this->filename_, ACE_LIB_TEXT ("at")); + { + // open a stream only if such doesn't exists + if (output_file == 0) + output_file = ACE_OS::fopen (this->filename_, ACE_LIB_TEXT ("at")); + } if (output_file == 0) return -1; #else - ofstream *output_file = 0; - if (this->log_msg_->msg_ostream ()) - delete this->log_msg_->msg_ostream (); // destructor will close it - + ostream *output_file = this->log_msg_->msg_ostream (); // Create a new ofstream to direct output to the file. if (wipeout_logfile_) + { + if (output_file) + delete output_file; ACE_NEW_RETURN (output_file, ofstream (ACE_TEXT_ALWAYS_CHAR (this->filename_)), -1); + } else - ACE_NEW_RETURN - (output_file, - ofstream (ACE_TEXT_ALWAYS_CHAR (this->filename_), - ios::app | ios::out), + { + if (output_file == 0) + ACE_NEW_RETURN + (output_file, + ofstream (ACE_TEXT_ALWAYS_CHAR (this->filename_), + ios::app | ios::out), -1); + } if (output_file->rdstate () != ios::goodbit) { delete output_file; @@ -376,7 +385,7 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, 0, SEEK_CUR) > this->max_size_) #else - if ((size_t) this->log_msg_->msg_ostream () > this->max_size_) + if ((size_t) this->log_msg_->msg_ostream ()->tellp () > this->max_size_) #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ { // Lock out any other logging. |