Logo Search packages:      
Sourcecode: pwlib version File versions

ostream & PTrace::End ( ostream &  strm  )  [static]

End a trace output. If the trace stream output is used outside of the provided macros, the PEndTrace# function must be used at the end of the section of trace output. A mutex is obtained on the call to PBeginTrace# which will prevent any other threads from using the trace stream until the PEndTrace. The PEndTrace# is used in a similar manner to #endl# or #flush#.

So a typical usage would be: {verbatim} ostream & s = PTrace::Begin(); s << "hello"; if (want_there) s << " there"; s << '!' << PTrace::End(); {verbatim}

Parameters:
strm  Trace output stream being completed

Definition at line 1066 of file osutils.cxx.

References SystemLogStream.

Referenced by PTrace::Block::Block(), and PTrace::Block::~Block().

{
  /* Only output if there is something to output, this prevents some blank trace
     entries from appearing under some patholgical conditions. Unfortunately if
     stderr is used the unitbuf flag causes the out_waiting() not to work so we 
     must suffer with blank lines in that case.
   */
#if 0
#ifndef P_LINUX
  ::streambuf & rb = *s.rdbuf();
  if (((s.flags()&ios::unitbuf) != 0) ||
#ifdef __USE_STL__
          rb.pubseekoff(0, ios::cur, ios::out) > 0
#else
          rb.out_waiting() > 0
#endif
      )
#endif
#endif
    {
    if ((PTraceOptions&SystemLogStream) != 0) {
      // Get the trace level for this message and set the stream width to that
      // level so that the PSystemLog can extract the log level back out of the
      // ios structure. There could be portability issues with this though it
      // should work pretty universally.
      s.width(PTraceCurrentLevel+1);
      s.flush();
    }
    else
      s << endl;
  }

  PTraceMutex->Signal();

  return s;
}


Generated by  Doxygen 1.6.0   Back to index