Fix up mapped logs.

This commit is contained in:
Glenn Maynard
2003-07-23 21:41:35 +00:00
parent 68f00eccf1
commit 5eb21182ac
+11 -6
View File
@@ -111,11 +111,11 @@ RageLog::RageLog()
RageLog::~RageLog() RageLog::~RageLog()
{ {
/* Add the mapped log data to info.txt. */ /* Add the mapped log data to info.txt. */
CString str; const char* p;
for(map<CString, CString>::const_iterator i = LogMaps.begin(); i != LogMaps.end(); ++i) int size;
str += ssprintf("%s\n", i->second.c_str()); GetAdditionalLog( p, size );
fprintf( m_fileInfo, "%s", str.c_str() ); fprintf( m_fileInfo, "%s", p );
fprintf( m_fileLog, "\nStatics:\n%s", str.c_str() ); fprintf( m_fileLog, "\nStatics:\n%s", p );
Flush(); Flush();
HideConsole(); HideConsole();
@@ -220,13 +220,16 @@ void RageLog::UpdateMappedLog()
for(map<CString, CString>::const_iterator i = LogMaps.begin(); i != LogMaps.end(); ++i) for(map<CString, CString>::const_iterator i = LogMaps.begin(); i != LogMaps.end(); ++i)
str += ssprintf("%s\n", i->second.c_str()); str += ssprintf("%s\n", i->second.c_str());
g_AdditionalLogSize = min( sizeof(g_AdditionalLogStr), str.size() ); g_AdditionalLogSize = min( sizeof(g_AdditionalLogStr), str.size()+1 );
memcpy( g_AdditionalLogStr, str.c_str(), g_AdditionalLogSize ); memcpy( g_AdditionalLogStr, str.c_str(), g_AdditionalLogSize );
g_AdditionalLogStr[ sizeof(g_AdditionalLogStr)-1 ] = 0;
/* XXX: deprecated */ /* XXX: deprecated */
HOOKS->AdditionalLog(str); HOOKS->AdditionalLog(str);
} }
/* Under normal conditions, p will always be null-terminated. "size" is provided
* for crash handlers--under crash conditions, it may not be. */
void RageLog::GetAdditionalLog( const char* &p, int &size ) void RageLog::GetAdditionalLog( const char* &p, int &size )
{ {
p = g_AdditionalLogStr; p = g_AdditionalLogStr;
@@ -239,6 +242,8 @@ void RageLog::MapLog(const CString &key, const char *fmt, ...)
va_start(va, fmt); va_start(va, fmt);
LogMaps[key] = vssprintf( fmt, va ); LogMaps[key] = vssprintf( fmt, va );
va_end(va); va_end(va);
UpdateMappedLog();
} }
void RageLog::UnmapLog(const CString &key) void RageLog::UnmapLog(const CString &key)