Go to the documentation of this file.
45 #define kLOGENV "TWAINDSM_LOG"
53 #define kLOGMODEENV "TWAINDSM_LOGMODE"
59 #define TWNDSM_MAX_MSG 1024
72 memset(&
pod,0,
sizeof(
pod));
128 kPANIC(
"Unable to allocate a buffer for logging...");
174 const char*
const _file,
176 const char*
const _format,
188 char *message = NULL;
189 const char *file = NULL;
192 #if (TWNDSM_CMP == TWNDSM_CMP_VISUALCPP)
193 nError = GetLastError();
199 #elif (TWNDSM_CMP == TWNDSM_CMP_GNUGPP)
202 #error Sorry, we do not recognize this system...
219 #if (TWNDSM_CMP == TWNDSM_CMP_VISUALCPP)
221 file = strrchr(_file,
'\\');
226 file = strrchr(_file,
'/');
240 #if (TWNDSM_CMP == TWNDSM_CMP_VISUALCPP)
248 "[%02d%02d%02d%03d %-8s %4d %5u %p] %.*s",
249 (
int)st.wHour, (
int)st.wMinute, (
int)st.wSecond,(
int)st.wMilliseconds,
254 #elif (TWNDSM_CMP == TWNDSM_CMP_GNUGPP)
257 gettimeofday(&tv,NULL);
259 localtime_r(&tv.tv_sec,&tm);
262 "[%02d%02d%02d%03d %-8s %4d %5d %p] %.*s",
263 tm.tm_hour,tm.tm_min,tm.tm_sec,(
int)(tv.tv_usec / 1000),
270 #error Sorry, we do not recognize this system...
279 va_start(valist,_format);
280 #if (TWNDSM_CMP == TWNDSM_CMP_VISUALCPP) && (TWNDSM_CMP_VERSION >= 1400)
281 _vsnprintf_s(message,nChars,nChars,_format,valist);
282 #elif (TWNDSM_CMP == TWNDSM_CMP_VISUALCPP)
283 _vsnprintf(message,nChars,_format,valist);
284 #elif (TWNDSM_CMP == TWNDSM_CMP_GNUGPP)
285 vsnprintf(message,nChars,_format,valist);
287 #error Sorry, we do not recognize this system...
Everything we need to make our .cpp files happy.
Our implementation class where we hide our attributes...
We use a pod system because it help prevents us from making dumb initialization mistakes....
void Log(const int _doassert, const char *const _file, const int _line, const char *const _format,...)
The logging function.
#define SGETENV(d, z, n)
Secure Get enviroment varable.
struct CTwnDsmLogImpl::_pod pod
Pieces of data for CTwnDsmAppsImpl.
#define kLOGENV
Enviroment varible of path to where to write the LogFile name.
char m_logpath[FILENAME_MAX]
where we put the file.
CTwnDsmLog()
The CTwnDsmLog constructor.
~CTwnDsmLog()
The CTwnDsmLog destructor.
#define SSTRCPY(d, z, s)
Secure String copy.
#define kPANIC(msg)
Display message to user.
char m_logmode[16]
how we fopen the file.
CTwnDsmLogImpl()
Make sure we're squeaky clean...
int m_nIndent
how far to indent the log message
void Indent(int nChange)
Indent the logging to help with seeing recursive calls param[in] nChange Either +1 or -1.
CTwnDsmLogImpl * m_ptwndsmlogimpl
The implementation pointer helps with encapulation.
char * m_message
buffer for our messages.
FILE * m_plog
where we'll dump information.
#define kLOGMODEENV
Enviroment varible of the fopen logmode to use (if you need to grow the log).
#define TWNDSM_MAX_MSG
Maximum message length we can handle...