Make sure we don't have problems with %'s in trace parameters.

Use va_end.
This commit is contained in:
Glenn Maynard
2002-08-26 06:40:49 +00:00
parent 657614d11a
commit 35b9371edb
2 changed files with 19 additions and 14 deletions
+10 -10
View File
@@ -34,7 +34,6 @@ RageLog::RageLog()
// Open log file and leave it open. Let the OS close it when the app exits
m_fileLog = fopen( LOG_FILE_NAME, "w" );
SYSTEMTIME st;
GetLocalTime( &st );
@@ -64,37 +63,38 @@ void RageLog::HideConsole()
FreeConsole();
}
void RageLog::Trace( LPCTSTR fmt, ...)
void RageLog::Trace( const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
CString sBuff = vssprintf( fmt, va );
sBuff += "\n";
va_end(va);
fprintf( m_fileLog, sBuff );
printf( sBuff );
fprintf( m_fileLog, "%s\n", sBuff );
printf( "%s\n", sBuff );
#ifdef DEBUG
this->Flush(); // implicit flush
#endif
}
void RageLog::Trace( HRESULT hr, LPCTSTR fmt, ...)
void RageLog::Trace( HRESULT hr, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
CString s = vssprintf( fmt, va );
va_end(va);
s += ssprintf( "(%s)", DXGetErrorString8(hr) );
this->Trace( s );
this->Trace( "%s", s );
}
void RageLog::Warn( LPCTSTR fmt, ...)
void RageLog::Warn( const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
CString sBuff = vssprintf( fmt, va );
va_end(va);
Trace( "/////////////////////////////////////////\n"
"WARNING: %s\n"
+9 -4
View File
@@ -1,4 +1,6 @@
#pragma once
#ifndef RAGELOG_H
#define RAGELOG_H
/*
-----------------------------------------------------------------------------
Class: RageLog
@@ -10,6 +12,7 @@
-----------------------------------------------------------------------------
*/
#include <stdio.h>
class RageLog
{
@@ -17,9 +20,9 @@ public:
RageLog();
~RageLog();
void Trace( LPCTSTR fmt, ...);
void Trace( HRESULT hr, LPCTSTR fmt, ...);
void Warn( LPCTSTR fmt, ...);
void Trace( const char *fmt, ...);
void Trace( HRESULT hr, const char *fmt, ...);
void Warn( const char *fmt, ...);
void Flush();
void ShowConsole();
@@ -30,3 +33,5 @@ protected:
};
extern RageLog* LOG; // global and accessable from anywhere in our program
#endif