Download source files - 3 Kb
This class makes it possible to use log file in multi-threaded
applications and has several useful features widely used in my
multi-threaded, time sensitive projects where Visual C++ integrated
debugger has very limited usage.
CDebugPrintf class provides some useful features:
Thread-safe logging in multi-threaded applications.
Automatic removing log messages from release version of your
You don't need anymore remove or comment log messages in
release version. Release version will not have any overhead
or unused information in executable file.
You can write log messages at same time to same file from different
It is useful when it is necessary to explore interaction and timing
issues between to two or more applications
printfs style for format text: %s, %d, %4.1d and etc.
Sorry, but there is no floating point support.
Data and time stamps for each message in log file.
Also this class provides time difference stamp from application
Console output and easy logging for error codes returned by
Saving old log files.
Uses only Windows API functons. So it can be used even in
The class is easy to use.
- Include files dbg.h and dbg.cpp to your project.
- At any time you want to write something to the log file, use the
Example of log file output:
0.000 08/25/2000 15:04:48 User name = KVA
0.015 08/25/2000 15:04:48 ISAPI = "TraxDataMgr.dll"
0.015 08/25/2000 15:04:48 CActionHandler constructor
0.015 08/25/2000 15:04:48 CDataMgrActionHandler constructor
5.123 08/25/2000 15:04:53 0 HttpExtensionProc: started
5.123 08/25/2000 15:04:53 Execute request 1 started.
5.672 08/25/2000 15:04:53 CIndexer constructor: done
5.693 08/25/2000 15:04:53 Open: D:\Data\Docs\customer
5.693 08/25/2000 15:04:53 Loading index table from 'D:\Data\Docs\customer.idx'
5.693 08/25/2000 15:04:53 Count: 93560
6.132 08/25/2000 15:04:54 Index loading finished ... OK
6.375 08/25/2000 15:04:54 Execute request 1 finished.
6.375 08/25/2000 15:04:54 0 HttpExtensionProc: finished
void SomeFunction( char* arg1, int arg2, string& arg3 )
PRINTF("Something happened by using %s and %d arguments", arg1, arg2);
PRINTF("This message is visible on console and in log-file.");
All log messages must fit into one line of source code because of
problem with transparent removing log messages from release version.
PRINTF("One line messages are supported.");
PRINTF("Multi-line messages %s %s",