Re #145 Level name only at the beginning of logged lines
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2664 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: c238323b1246f8036caf7b37013970d2c4c03f73 Former-commit-id: 6808f814bd5c1f44252ddfda794d51e55f696a08
This commit is contained in:
parent
4554097f8d
commit
ea9f7fbeb4
3 changed files with 84 additions and 59 deletions
|
@ -408,7 +408,7 @@ initPits(void)
|
|||
}
|
||||
|
||||
for (teamsIterator = teams.begin(); teamsIterator != teams.end(); ++teamsIterator) {
|
||||
printf("----------------- %s\t%d\n", (teamsIterator->first).c_str(), teamsIterator->second);
|
||||
GfLogDebug("----------------- %s\t%d\n", (teamsIterator->first).c_str(), teamsIterator->second);
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -798,13 +798,13 @@ ReInitCars(void)
|
|||
if (robhdle && ( strcmp( robotModuleName, "human" ) == 0 || strcmp( robotModuleName, "networkhuman" ) == 0 ) )
|
||||
{
|
||||
/* Human driver */
|
||||
printf( "robotModuleName (1): %s\n", robotModuleName );
|
||||
GfLogDebug( "robotModuleName (1): %s\n", robotModuleName );
|
||||
elt = reLoadSingleCar( index, i, robotIdx - (*(ReInfo->modList))->modInfo[0].index, robotIdx, FALSE, robotModuleName );
|
||||
}
|
||||
else if (robhdle && ( strcmp( GfParmGetStr( robhdle, ROB_SECT_ARBITRARY, ROB_ATTR_TEAM, "foo" ),
|
||||
GfParmGetStr( robhdle, ROB_SECT_ARBITRARY, ROB_ATTR_TEAM, "bar" ) ) == 0 ) )
|
||||
{
|
||||
printf( "robotModuleName: %s\n", robotModuleName );
|
||||
GfLogDebug( "robotModuleName: %s\n", robotModuleName );
|
||||
elt = reLoadSingleCar( index, i, (*(ReInfo->modList))->modInfoSize, robotIdx, FALSE, robotModuleName );
|
||||
}
|
||||
else
|
||||
|
@ -970,7 +970,7 @@ ReInitTrack(void)
|
|||
Timeday = GfParmGetNum(params, raceName, RM_ATTR_TIME, NULL, 0);
|
||||
cloud = GfParmGetNum(params, raceName, RM_ATTR_WEATHER, NULL, 0);
|
||||
|
||||
printf("Race Name = %s\n", raceName);
|
||||
GfLogDebug("Race Name = %s\n", raceName);
|
||||
sprintf(buf, "tracks/%s/%s/%s.%s", catName, trackName, trackName, TRKEXT);
|
||||
ReInfo->track = ReInfo->_reTrackItf.trkBuild(buf);
|
||||
|
||||
|
@ -988,7 +988,7 @@ ReInitTrack(void)
|
|||
curSurf = track->surfaces;
|
||||
do
|
||||
{
|
||||
printf("Raceinit Function Friction = %f - RollRes = %f\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
GfLogDebug("Raceinit Function Friction = %f - RollRes = %f\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
curSurf = curSurf->next;
|
||||
} while ( curSurf != 0);
|
||||
#endif
|
||||
|
|
|
@ -51,7 +51,7 @@ static int GfFileSetupCopyFile( const char* dataLocation, const char* localLocat
|
|||
return -1;
|
||||
}
|
||||
|
||||
GfOut("Updating %s\n", localLocation);
|
||||
GfLogTrace("Updating %s\n", localLocation);
|
||||
|
||||
while( !feof( in ) )
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ void GfFileSetup()
|
|||
absLocalLocation = (char*)malloc( sizeof(char)*(strlen(GetLocalDir())+strlen(localLocation)+3) );
|
||||
sprintf( absLocalLocation, "%s%s", GetLocalDir(), localLocation );
|
||||
|
||||
GfOut("Checking %s : new release is %d.%d, ", localLocation, major, minor);
|
||||
GfLogTrace("Checking %s : user settings version ", localLocation);
|
||||
|
||||
// Search for its old major and minor version numbers in the user settings.
|
||||
if( GfParmListSeekFirst( localVersionHandle, "versions" ) == 0 )
|
||||
|
@ -213,14 +213,16 @@ void GfFileSetup()
|
|||
const int locMinor = (int)GfParmGetCurNum( localVersionHandle, "versions", "Minor version", NULL, 0 );
|
||||
const int locMajor = (int)GfParmGetCurNum( localVersionHandle, "versions", "Major version", NULL, 0 );
|
||||
|
||||
GfOut("old release %d.%d => ", locMajor, locMinor);
|
||||
GfLogTrace("%d.%d is ", locMajor, locMinor);
|
||||
|
||||
if( locMajor != major || locMinor < minor)
|
||||
{
|
||||
GfOut("updating ...\n");
|
||||
GfLogTrace("obsolete (installed one is %d.%d) => updating ...\n",
|
||||
major, minor);
|
||||
GfFileSetupCopy( dataLocation, absLocalLocation, major, minor, localVersionHandle, -1 );
|
||||
}
|
||||
else
|
||||
GfOut("up-to-date.\n");
|
||||
GfLogTrace("up-to-date.\n");
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -232,7 +234,7 @@ void GfFileSetup()
|
|||
index = 0;
|
||||
while( count[index] )
|
||||
++index;
|
||||
GfOut("no yet referenced => installing ...\n");
|
||||
GfLogTrace("not found => installing ...\n");
|
||||
GfFileSetupCopy( dataLocation, absLocalLocation, major, minor, localVersionHandle, index );
|
||||
count[index] = TRUE;
|
||||
}
|
||||
|
|
|
@ -55,11 +55,15 @@ static FILE* gfLogStream = 0;
|
|||
// Log level threshold.
|
||||
static int gfLogLevelThreshold = -1;
|
||||
|
||||
// Flag indicating if the last logged line ended with a new-line.
|
||||
static bool gfLogNeedLineHeader = true;
|
||||
|
||||
#endif // TRACE_OUT
|
||||
|
||||
void
|
||||
gfTraceInit(void)
|
||||
{
|
||||
gfLogNeedLineHeader = true;
|
||||
GfLogSetLevelThreshold(TRACE_LEVEL);
|
||||
GfLogSetStream(stderr);
|
||||
}
|
||||
|
@ -122,12 +126,14 @@ void GfLogFatal(const char *pszFmt, ...)
|
|||
#ifdef TRACE_OUT
|
||||
if (gfLogLevelThreshold >= gfLogFatal)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Fatal\t");
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
#endif // TRACE_OUT
|
||||
|
||||
|
@ -142,12 +148,14 @@ TGF_API void GfLogError(const char *pszFmt, ...)
|
|||
{
|
||||
if (gfLogLevelThreshold >= gfLogError)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Error\t");
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,12 +163,14 @@ TGF_API void GfLogWarning(const char *pszFmt, ...)
|
|||
{
|
||||
if (gfLogLevelThreshold >= gfLogWarning)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Warning\t");
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,12 +178,14 @@ TGF_API void GfLogInfo(const char *pszFmt, ...)
|
|||
{
|
||||
if (gfLogLevelThreshold >= gfLogInfo)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Info\t");
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,12 +193,14 @@ TGF_API void GfLogTrace(const char *pszFmt, ...)
|
|||
{
|
||||
if (gfLogLevelThreshold >= gfLogTrace)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Trace\t");
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,12 +208,14 @@ TGF_API void GfLogDebug(const char *pszFmt, ...)
|
|||
{
|
||||
if (gfLogLevelThreshold >= gfLogDebug)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Debug\t");
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,14 +224,21 @@ TGF_API void GfLogMessage(int nLevel, const char *pszFmt, ...)
|
|||
if (gfLogLevelThreshold >= nLevel)
|
||||
{
|
||||
if (nLevel >= gfLogFatal && nLevel <= gfLogDebug)
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "%s\t", gfLogLevelNames[nLevel]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gfLogNeedLineHeader)
|
||||
fprintf(gfLogStream, "Level%d\t", nLevel);
|
||||
}
|
||||
va_list vaArgs;
|
||||
va_start(vaArgs, pszFmt);
|
||||
vfprintf(gfLogStream, pszFmt, vaArgs);
|
||||
va_end(vaArgs);
|
||||
fflush(gfLogStream);
|
||||
gfLogNeedLineHeader = strrchr(pszFmt, '\n') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue