Trace.h

Go to the documentation of this file.
00001 /*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
00002  *
00003  *  Use of this source code is governed by a zlib-style license that can
00004  *  be found in the License.txt file in the root of the source tree.
00005  */
00006 
00007 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00008 //
00009 // Trace
00010 //
00011 // Provide a direct to file trace
00012 //
00013 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00014 
00015 //---------------------------------------------------------------------------
00016 #ifndef ZenTraceH
00017 #define ZenTraceH
00018 //---------------------------------------------------------------------------
00019 
00020 //---------------------------------------------------------------------------
00021 #include <fstream>
00022 #include "ZenLib/Ztring.h"
00023 //---------------------------------------------------------------------------
00024 
00025 namespace ZenLib
00026 {
00027 
00028 //***************************************************************************
00029 
00030 static std::FILE* Trace_F;
00031 static ZenLib::Ztring Trace;
00032 static ZenLib::Ztring Trace2;
00033 
00034 #ifdef TRACE
00035     #undef TRACE
00036 #endif //TRACE
00037 
00038 #if 1
00039 #define TRACE(_TOAPPEND)
00040 #else
00041 #define TRACE(_TOAPPEND) \
00042 Trace.clear(); \
00043 Trace2.clear(); \
00044 _TOAPPEND; \
00045 if (!Trace2.empty()) \
00046 { \
00047     Trace+=__T(" - "); \
00048     Trace+=Trace2; \
00049 } \
00050 Trace+=__T("\r\n"); \
00051 Trace_F=std::fopen("Trace.txt", "a+t"); \
00052 if(Trace_F) \
00053 { \
00054   std::fwrite(Trace.To_Local().c_str(), Trace.size(), 1, Trace_F); \
00055   std::fclose(Trace_F); \
00056 }
00057 #endif
00058 
00059 //***************************************************************************
00060 
00061 
00062 } //NameSpace
00063 
00064 #endif // ZenTraceH

Generated on Sun Mar 5 00:13:54 2017 for ZenLib by  doxygen 1.4.7