Skip to content

Commit

Permalink
Logging part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
TimePath authored and Kangz committed Feb 6, 2016
1 parent 09999e6 commit 37f1f36
Show file tree
Hide file tree
Showing 72 changed files with 605 additions and 734 deletions.
2 changes: 2 additions & 0 deletions daemon/src/common/Log.cpp
Expand Up @@ -44,6 +44,8 @@ namespace Log {
}
}

Logger defaultLogger("common.default", "", Level::NOTICE);

bool ParseCvarValue(std::string value, Log::Level& result) {
if (value == "warning" or value == "warn") {
result = Log::Level::WARNING;
Expand Down
7 changes: 4 additions & 3 deletions daemon/src/common/Log.h
Expand Up @@ -234,15 +234,16 @@ namespace Log {
}

// Quick Logs
extern Logger defaultLogger;

template<typename ... Args>
void Warn(Str::StringRef format, Args&& ... args) {
CodeSourceWarn(Str::Format(format, std::forward<Args>(args) ...));
defaultLogger.Warn(format, std::forward<Args>(args) ...);
}

template<typename ... Args>
void Notice(Str::StringRef format, Args&& ... args) {
CodeSourceNotice(Str::Format(format, std::forward<Args>(args) ...));
defaultLogger.Notice(format, std::forward<Args>(args) ...);
}

template<typename ... Args>
Expand All @@ -252,7 +253,7 @@ namespace Log {

template<typename ... Args>
void Debug(Str::StringRef format, Args&& ... args) {
CodeSourceDebug(Str::Format(format, std::forward<Args>(args) ...));
defaultLogger.Debug(format, std::forward<Args>(args) ...);
}
}

Expand Down
22 changes: 11 additions & 11 deletions daemon/src/engine/botlib/bot_load.cpp
Expand Up @@ -169,13 +169,13 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( !f )
{
Com_Log(log_level_t::ERROR, "Cannot open Navigaton Mesh file" );
Log::Warn("Cannot open Navigaton Mesh file" );
return false;
}

if ( len < 0 )
{
Com_Log(log_level_t::ERROR, "Negative Length for Navigation Mesh file");
Log::Warn("Negative Length for Navigation Mesh file");
return false;
}

Expand All @@ -187,14 +187,14 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( header.magic != NAVMESHSET_MAGIC )
{
Com_Log(log_level_t::ERROR, "File is wrong magic" );
Log::Warn("File is wrong magic" );
FS_FCloseFile( f );
return false;
}

if ( header.version != NAVMESHSET_VERSION )
{
Com_Logf(log_level_t::ERROR, "File is wrong version found: %d want: %d", header.version, NAVMESHSET_VERSION );
Log::Warn("File is wrong version found: %d want: %d", header.version, NAVMESHSET_VERSION );
FS_FCloseFile( f );
return false;
}
Expand All @@ -203,7 +203,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( !nav.mesh )
{
Com_Log(log_level_t::ERROR, "Unable to allocate nav mesh" );
Log::Warn("Unable to allocate nav mesh" );
FS_FCloseFile( f );
return false;
}
Expand All @@ -212,7 +212,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( dtStatusFailed( status ) )
{
Com_Log(log_level_t::ERROR, "Could not init navmesh" );
Log::Warn("Could not init navmesh" );
dtFreeNavMesh( nav.mesh );
nav.mesh = nullptr;
FS_FCloseFile( f );
Expand All @@ -223,7 +223,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( !nav.cache )
{
Com_Log(log_level_t::ERROR, "Could not allocate tile cache" );
Log::Warn("Could not allocate tile cache" );
dtFreeNavMesh( nav.mesh );
nav.mesh = nullptr;
FS_FCloseFile( f );
Expand All @@ -234,7 +234,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( dtStatusFailed( status ) )
{
Com_Log(log_level_t::ERROR, "Could not init tile cache" );
Log::Warn("Could not init tile cache" );
dtFreeNavMesh( nav.mesh );
dtFreeTileCache( nav.cache );
nav.mesh = nullptr;
Expand All @@ -253,7 +253,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( !tileHeader.tileRef || !tileHeader.dataSize )
{
Com_Log(log_level_t::ERROR, "NUll Tile in navmesh" );
Log::Warn("NUll Tile in navmesh" );
dtFreeNavMesh( nav.mesh );
dtFreeTileCache( nav.cache );
nav.cache = nullptr;
Expand All @@ -266,7 +266,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( !data )
{
Com_Log(log_level_t::ERROR, "Failed to allocate memory for tile data" );
Log::Warn("Failed to allocate memory for tile data" );
dtFreeNavMesh( nav.mesh );
dtFreeTileCache( nav.cache );
nav.cache = nullptr;
Expand All @@ -289,7 +289,7 @@ bool BotLoadNavMesh( const char *filename, NavData_t &nav )

if ( dtStatusFailed( status ) )
{
Com_Log(log_level_t::ERROR, "Failed to add tile to navmesh" );
Log::Warn("Failed to add tile to navmesh" );
dtFree( data );
dtFreeTileCache( nav.cache );
dtFreeNavMesh( nav.mesh );
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/botlib/bot_local.cpp
Expand Up @@ -82,7 +82,7 @@ void FindWaypoints( Bot_t *bot, float *corners, unsigned char *cornerFlags, dtPo
{
if ( !bot->corridor.getPathCount() )
{
Com_Log(log_level_t::ERROR, "FindWaypoints Called without a path!" );
Log::Warn("FindWaypoints Called without a path!" );
*numCorners = 0;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/engine/client/cin_ogm.cpp
Expand Up @@ -318,7 +318,7 @@ static int loadVideoFrameTheora()
{
g_ogm.outputWidht = g_ogm.th_info.width;
g_ogm.outputHeight = g_ogm.th_info.height;
Com_DPrintf( "[Theora(ogg)]new resolution %dx%d\n", g_ogm.outputWidht, g_ogm.outputHeight );
Log::Debug( "[Theora(ogg)]new resolution %dx%d", g_ogm.outputWidht, g_ogm.outputHeight );
}

if ( g_ogm.outputBufferSize < g_ogm.th_info.width * g_ogm.th_info.height )
Expand Down Expand Up @@ -688,7 +688,7 @@ int Cin_OGM_Init( const char *filename )
g_ogm.Vtime_unit = ( ( ogg_int64_t ) g_ogm.th_info.fps_denominator * 1000 * 10000 / g_ogm.th_info.fps_numerator );
}

Com_DPrintf( "OGM-Init done (%s)\n", filename );
Log::Debug( "OGM-Init done (%s)", filename );

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/client/cl_avi.cpp
Expand Up @@ -337,7 +337,7 @@ bool CL_OpenAVIForWriting( const char *fileName )
// Don't start if a framerate has not been chosen
if ( cl_aviFrameRate->integer <= 0 )
{
Com_Log(log_level_t::ERROR, "cl_aviFrameRate must be ≥ 1\n" );
Log::Warn("cl_aviFrameRate must be ≥ 1" );
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions daemon/src/engine/client/cl_cgame.cpp
Expand Up @@ -606,7 +606,7 @@ static int LAN_ServerIsVisible( int source, int n )

if ( Cmd_Argc() == 1 )
{
Com_Log(log_level_t::ERROR, "Server sent a pubkey_decrypt command, but sent nothing to decrypt!" );
Log::Warn("Server sent a pubkey_decrypt command, but sent nothing to decrypt!" );
return false;
}

Expand Down Expand Up @@ -714,7 +714,7 @@ void CL_InitCGame()

t2 = Sys_Milliseconds();

Com_DPrintf( "CL_InitCGame: %5.2fs\n", ( t2 - t1 ) / 1000.0 );
Log::Debug( "CL_InitCGame: %5.2fs", ( t2 - t1 ) / 1000.0 );

// have the renderer touch all its images, so they are present
// on the card even if the driver does deferred loading
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/engine/client/cl_cin.cpp
Expand Up @@ -96,7 +96,7 @@ e_status CIN_StopCinematic( int handle )

currentHandle = handle;

Com_DPrintf( "trFMV::stop(), closing %s\n", cinTable[ currentHandle ].fileName );
Log::Debug( "trFMV::stop(), closing %s", cinTable[ currentHandle ].fileName );

if ( !cinTable[ currentHandle ].buf )
{
Expand Down Expand Up @@ -371,7 +371,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
}
}

Com_DPrintf( "SCR_PlayCinematic( %s )\n", arg );
Log::Debug( "SCR_PlayCinematic( %s )", arg );

Com_Memset( &cin, 0, sizeof( cinematics_t ) );
currentHandle = CIN_HandleForVideo();
Expand Down Expand Up @@ -556,7 +556,7 @@ void CL_PlayCinematic_f()
return;
}

Com_DPrintf( "CL_PlayCinematic_f\n" );
Log::Debug( "CL_PlayCinematic_f" );

if ( cls.state == connstate_t::CA_CINEMATIC )
{
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/client/cl_console.cpp
Expand Up @@ -166,7 +166,7 @@ void Con_Dump_f()

if ( !f )
{
Com_Log(log_level_t::ERROR, "couldn't open." );
Log::Warn("couldn't open." );
return;
}

Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/client/cl_input.cpp
Expand Up @@ -95,7 +95,7 @@ void IN_KeyDown( kbutton_t *b )
}
else
{
Com_DPrintf( "Three keys down for a button!" );
Log::Debug( "Three keys down for a button!" );
return;
}

Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/client/cl_keys.cpp
Expand Up @@ -1995,7 +1995,7 @@ void Key_SetTeam( int newTeam )

if ( bindTeam != newTeam )
{
Com_DPrintf( "%sSetting binding team index to %d\n",
Log::Debug( "%sSetting binding team index to %d",
Color::CString( Color::Green ),
newTeam );
}
Expand Down

0 comments on commit 37f1f36

Please sign in to comment.