summaryrefslogtreecommitdiff
path: root/tests/Test_Output.cpp
diff options
context:
space:
mode:
authorharris_s <harris_s@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-11-04 23:11:00 +0000
committerharris_s <harris_s@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-11-04 23:11:00 +0000
commit8cf6309c1ddb0ea3121b2eff75e72ead56d5ade0 (patch)
tree9fc9b6460b5860e760617707506ba58df0ba0eaf /tests/Test_Output.cpp
parent75045a05a6fb17bd701e7f8c86961d175945f3c0 (diff)
downloadATCD-8cf6309c1ddb0ea3121b2eff75e72ead56d5ade0.tar.gz
Thu Nov 4 17:06:08 CST 2004 Scott Harris <harris_s@ociweb.com>
Diffstat (limited to 'tests/Test_Output.cpp')
-rw-r--r--tests/Test_Output.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/Test_Output.cpp b/tests/Test_Output.cpp
index adb9e9e8e46..ed0e180faa8 100644
--- a/tests/Test_Output.cpp
+++ b/tests/Test_Output.cpp
@@ -48,6 +48,8 @@ ACE_Test_Output::ACE_Test_Output (void)
ACE_Test_Output::~ACE_Test_Output (void)
{
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) && !defined (ACE_PSOS)
+ ACE_OSTREAM_TYPE *log_msg_stream = ACE_LOG_MSG->msg_ostream ();
+
ACE_LOG_MSG->msg_ostream (&cerr);
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY && ! ACE_PSOS */
@@ -55,14 +57,21 @@ ACE_Test_Output::~ACE_Test_Output (void)
ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) && !defined (ACE_HAS_PHARLAP)
- delete this->output_file_;
+ if (this->output_file_ == log_msg_stream)
+ delete this->output_file_;
+ // else something else changed the stream and hence should
+ // have closed and deleted the output_file_
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
}
OFSTREAM *
ACE_Test_Output::output_file (void)
{
- return this->output_file_;
+ // the output_file_ is given to ACE_LOG_MSG
+ // and something else might destroy and/or change the stream
+ // so return what ACE_LOG_MSG is using.
+ return dynamic_cast<OFSTREAM*>( ACE_LOG_MSG->msg_ostream () );
+ //return this->output_file_;
}
int
@@ -146,7 +155,7 @@ ACE_Test_Output::set_output (const ACE_TCHAR *filename, int append)
this->output_file_ = ACE_OS::fopen (temp, fmode);
# endif /* ACE_LACKS_IOSTREAM_TOTALLY */
- ACE_LOG_MSG->msg_ostream (this->output_file ());
+ ACE_LOG_MSG->msg_ostream (this->output_file_);
#endif /* ACE_HAS_PHARLAP */
ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER );
@@ -159,8 +168,13 @@ void
ACE_Test_Output::close (void)
{
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
- this->output_file_->flush ();
- this->output_file_->close ();
+ if (this->output_file_ == ACE_LOG_MSG->msg_ostream () )
+ {
+ this->output_file_->flush ();
+ this->output_file_->close ();
+ }
+ // else something else changed the stream and hence should
+ // have closed and deleted the output_file_
#else
ACE_OS::fflush (this->output_file_);
ACE_OS::fclose (this->output_file_);