[Com0com-cvs] hub4com/plugins/trace filter.cpp, 1.1, 1.2 precomp.h, 1.1, 1.2
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
From: Vyacheslav F. <vf...@us...> - 2008-08-29 15:17:12
|
Update of /cvsroot/com0com/hub4com/plugins/trace In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14204 Modified Files: filter.cpp precomp.h Log Message: Added printing command line and config Index: precomp.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/trace/precomp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** precomp.h 29 Aug 2008 13:13:04 -0000 1.1 --- precomp.h 29 Aug 2008 15:17:07 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/08/29 15:17:07 vfrolov + * Added printing command line and config + * * Revision 1.1 2008/08/29 13:13:04 vfrolov * Initial revision *************** *** 35,38 **** --- 38,42 ---- #include <sstream> #include <iomanip> + #include <set> using namespace std; Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/trace/filter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** filter.cpp 29 Aug 2008 13:13:04 -0000 1.1 --- filter.cpp 29 Aug 2008 15:17:07 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/08/29 15:17:07 vfrolov + * Added printing command line and config + * * Revision 1.1 2008/08/29 13:13:04 vfrolov * Initial revision *************** *** 38,41 **** --- 41,46 ---- static ROUTINE_FILTER_NAME_A *pFilterName = NULL; /////////////////////////////////////////////////////////////// + static void PrintTime(ostream &tout); + /////////////////////////////////////////////////////////////// const char *GetParam(const char *pArg, const char *pPattern) { *************** *** 50,61 **** class TraceConfig { public: ! TraceConfig() : pTraceStream(&cout) {} void SetTracePath(const char *pPath); ostream *GetTraceStream(); private: string path; ostream *pTraceStream; }; --- 55,72 ---- class TraceConfig { public: ! TraceConfig() : pTraceStream(NULL) {} void SetTracePath(const char *pPath); ostream *GetTraceStream(); + void PrintToAllTraceStreams(const char *pStr); + stringstream buf; private: string path; ostream *pTraceStream; + + typedef set<ostream*> Streams; + + Streams traceStreams; }; *************** *** 69,85 **** return pTraceStream; ! ofstream *pStream = new ofstream(path.c_str()); ! if (!pStream) { ! cerr << "No enough memory." << endl; ! exit(2); ! } ! if (!pStream->is_open()) { ! cerr << "Can't open " << path.c_str() << endl; ! exit(2); } ! return pTraceStream = pStream; } /////////////////////////////////////////////////////////////// --- 80,110 ---- return pTraceStream; ! if (path.empty()) { ! pTraceStream = &cout; ! } else { ! ofstream *pStream = new ofstream(path.c_str()); ! if (!pStream) { ! cerr << "No enough memory." << endl; ! exit(2); ! } ! if (!pStream->is_open()) { ! cerr << "Can't open " << path.c_str() << endl; ! exit(2); ! } ! ! pTraceStream = pStream; } ! traceStreams.insert(pTraceStream); ! ! return pTraceStream; ! } ! ! void TraceConfig::PrintToAllTraceStreams(const char *pStr) ! { ! for (Streams::const_iterator iS = traceStreams.begin() ; iS != traceStreams.end() ; iS++) ! (**iS) << pStr; } /////////////////////////////////////////////////////////////// *************** *** 169,172 **** --- 194,204 ---- } + PrintTime(pConfig->buf); + pConfig->buf << "Command Line:" << endl + << " {" << GetCommandLine() << "}" << endl; + + PrintTime(pConfig->buf); + pConfig->buf << "Config: {"; + return (HCONFIG)pConfig; } *************** *** 178,181 **** --- 210,215 ---- _ASSERTE(hConfig != NULL); + ((TraceConfig *)hConfig)->buf << endl << " {" << pArg << "}"; + const char *pParam; *************** *** 194,197 **** --- 228,234 ---- _ASSERTE(hConfig != NULL); + ((TraceConfig *)hConfig)->buf << endl << "}" << endl; + ((TraceConfig *)hConfig)->PrintToAllTraceStreams(((TraceConfig *)hConfig)->buf.str().c_str()); + delete (TraceConfig *)hConfig; } |