Skip to content

Commit

Permalink
Refactor|Log: Extra verbose entries only created if enabled in LogBuffer
Browse files Browse the repository at this point in the history
Do not waste time and memory for buffering extra verbose log entries
if they won’t be visible in the LogBuffer.
  • Loading branch information
skyjake committed Jan 29, 2017
1 parent 5e6c079 commit 1986306
Show file tree
Hide file tree
Showing 85 changed files with 407 additions and 347 deletions.
9 changes: 5 additions & 4 deletions doomsday/apps/client/src/audio/base/audiosystem.cpp
Expand Up @@ -53,6 +53,7 @@
#include <de/App>
#include <de/CommandLine>
#include <de/FileSystem>
#include <de/LogBuffer>
#include <de/NativeFile>
#include <de/timer.h>
#include <de/c_wrapper.h>
Expand Down Expand Up @@ -1149,7 +1150,7 @@ DENG2_PIMPL(AudioSystem)
if (nowTime - sfxLogicLastPurge < SOUND_LOGICAL_PURGEINTERVAL) return;

// Peform the purge now.
LOGDEV_AUDIO_XVERBOSE("purging logic sound hash...");
LOGDEV_AUDIO_XVERBOSE("purging logic sound hash...", "");
sfxLogicLastPurge = nowTime;

// Check all sounds in the hash.
Expand Down Expand Up @@ -2142,8 +2143,8 @@ dint AudioSystem::playSound(sfxsample_t *sample, dfloat volume, dfloat freq, mob
{
// The new sound can't be played because we were unable to stop
// enough channels to accommodate the limitation.
LOG_AUDIO_XVERBOSE("Not playing soundId:%i because all channels are busy")
<< sample->id;
LOG_AUDIO_XVERBOSE("Not playing soundId:%i because all channels are busy",
sample->id);
return false;
}

Expand Down Expand Up @@ -2238,7 +2239,7 @@ dint AudioSystem::playSound(sfxsample_t *sample, dfloat volume, dfloat freq, mob
{
// A suitable channel was not found.
allowSfxRefresh(true);
LOG_AUDIO_XVERBOSE("Failed to find suitable channel for sample id:%i") << sample->id;
LOG_AUDIO_XVERBOSE("Failed to find suitable channel for sample id:%i", sample->id);
return false;
}

Expand Down
36 changes: 18 additions & 18 deletions doomsday/apps/client/src/client/cl_mobj.cpp
Expand Up @@ -38,6 +38,7 @@

#include <de/timer.h>
#include <de/vector1.h>
#include <de/LogBuffer>
#include <cmath>

using namespace de;
Expand Down Expand Up @@ -81,9 +82,9 @@ void ClMobj_Link(mobj_t *mo)
// Client mobjs that belong to players remain unlinked.
return;
}
LOG_MAP_XVERBOSE("ClMobj_Link: id %i, x%f Y%f, solid:%b")
<< mo->thinker.id << mo->origin[VX] << mo->origin[VY]
<< (mo->ddFlags & DDMF_SOLID);
LOG_NET_XVERBOSE("ClMobj_Link: id %i, x%f Y%f, solid:%b",
mo->thinker.id << mo->origin[VX] << mo->origin[VY]
<< (mo->ddFlags & DDMF_SOLID));

Mobj_Link(mo, (mo->ddFlags & DDMF_DONTDRAW ? 0 : MLF_SECTOR) |
(mo->ddFlags & DDMF_SOLID ? MLF_BLOCKMAP : 0));
Expand All @@ -98,12 +99,12 @@ void ClMobj_EnableLocalActions(mobj_t *mo, dd_bool enable)
if (!isClient || !info) return;
if (enable)
{
LOG_NET_VERBOSE("Enabled for clmobj %i") << mo->thinker.id;
LOGDEV_NET_VERBOSE("Enabled for clmobj %i") << mo->thinker.id;
info->flags |= CLMF_LOCAL_ACTIONS;
}
else
{
LOG_NET_VERBOSE("Disabled for clmobj %i") << mo->thinker.id;
LOGDEV_NET_VERBOSE("Disabled for clmobj %i") << mo->thinker.id;
info->flags &= ~CLMF_LOCAL_ACTIONS;
}
}
Expand Down Expand Up @@ -271,7 +272,7 @@ dd_bool ClMobj_Reveal(mobj_t *mob)
return false;
}

LOG_MAP_XVERBOSE("clmobj %i 'Hidden' status lifted (z=%f)") << mob->thinker.id << mob->origin[VZ];
LOGDEV_MAP_XVERBOSE("clmobj %i 'Hidden' status lifted (z=%f)", mob->thinker.id << mob->origin[VZ]);

info->flags &= ~CLMF_HIDDEN;

Expand All @@ -284,10 +285,9 @@ dd_bool ClMobj_Reveal(mobj_t *mob)
S_StartSoundAtVolume(info->sound, mob, info->volume);
}

LOGDEV_MAP_XVERBOSE("Revealing id %i, state %p (%i)")
<< mob->thinker.id
<< mob->state
<< ::runtimeDefs.states.indexOf(mob->state);
LOGDEV_MAP_XVERBOSE("Revealing id %i, state %p (%i)",
mob->thinker.id << mob->state <<
::runtimeDefs.states.indexOf(mob->state));

return true;
}
Expand Down Expand Up @@ -348,16 +348,16 @@ void ClMobj_ReadDelta()
fastMom = true;
}

LOG_NET_XVERBOSE("Reading mobj delta for %i (df:0x%x edf:0x%x)")
<< id << df << moreFlags;
LOGDEV_NET_XVERBOSE("Reading mobj delta for %i (df:0x%x edf:0x%x)",
id << df << moreFlags);

// Get the client mobj for this.
mobj_t *mo = map.clMobjFor(id);
ClientMobjThinkerData::RemoteSync *info = ClMobj_GetInfo(mo);
bool needsLinking = false, justCreated = false;
if (!mo)
{
LOG_NET_XVERBOSE("Creating new clmobj %i (hidden)") << id;
LOG_NET_XVERBOSE("Creating new clmobj %i (hidden)", id);

// This is a new ID, allocate a new mobj.
mo = map.clMobjFor(id, true /* create it now */);
Expand Down Expand Up @@ -567,9 +567,9 @@ void ClMobj_ReadDelta()
// Update players.
if (d->dPlayer)
{
LOG_NET_XVERBOSE("Updating player %i local mobj with new clmobj state {%f, %f, %f}")
<< P_GetDDPlayerIdx(d->dPlayer)
<< d->origin[VX] << d->origin[VY] << d->origin[VZ];
LOG_NET_XVERBOSE("Updating player %i local mobj with new clmobj state {%f, %f, %f}",
P_GetDDPlayerIdx(d->dPlayer) <<
d->origin[VX] << d->origin[VY] << d->origin[VZ]);

// Players have real mobjs. The client mobj is hidden (unlinked).
Cl_UpdateRealPlayerMobj(d->dPlayer->mo, d, df, onFloor);
Expand All @@ -586,7 +586,7 @@ void ClMobj_ReadNullDelta()

// The delta only contains an ID.
thid_t id = Reader_ReadUInt16(msgReader);
LOGDEV_NET_XVERBOSE("Null %i") << id;
LOGDEV_NET_XVERBOSE("Null %i", id);

mobj_t *mo = map.clMobjFor(id);
if (!mo)
Expand Down Expand Up @@ -621,7 +621,7 @@ void ClMobj_ReadNullDelta()
mobj_t *ClMobj_Find(thid_t id)
{
if (!App_World().hasMap()) return nullptr;

/// @todo Do not assume the CURRENT map.
return App_World().map().clMobjFor(id);
}
Expand Down
9 changes: 5 additions & 4 deletions doomsday/apps/client/src/client/cl_player.cpp
Expand Up @@ -30,6 +30,7 @@
#include "BspLeaf"
#include "Sector"

#include <de/LogBuffer>
#include <de/Vector>

using namespace de;
Expand Down Expand Up @@ -353,8 +354,8 @@ void ClPlayer_ReadDelta()
// The update will be made when the mobj data is received.
if (!justCreated) // && num != consolePlayer)
{
LOGDEV_NET_XVERBOSE("Copying clmo %i state to real player %i mobj %p")
<< newId << num << ddpl->mo;
LOGDEV_NET_XVERBOSE("Copying clmo %i state to real player %i mobj %p",
newId << num << ddpl->mo);

Cl_UpdateRealPlayerMobj(ddpl->mo, clmo, 0xffffffff, true);
}
Expand Down Expand Up @@ -417,8 +418,8 @@ void ClPlayer_ReadDelta()
{
ddpl->flags &= ~DDPF_REMOTE_VIEW_FILTER;
}
LOG_NET_XVERBOSE("View filter color set remotely to %s")
<< Vector4f(ddpl->filterColor).asText();
LOG_NET_XVERBOSE("View filter color set remotely to %s",
Vector4f(ddpl->filterColor).asText());
}

if (df & PDF_PSPRITES)
Expand Down
8 changes: 5 additions & 3 deletions doomsday/apps/client/src/client/cl_sound.cpp
Expand Up @@ -31,6 +31,8 @@
#include "world/p_players.h"
#include "Sector"

#include <de/LogBuffer>

using namespace de;

void Cl_ReadSoundDelta(deltatype_t type)
Expand Down Expand Up @@ -77,7 +79,7 @@ void Cl_ReadSoundDelta(deltatype_t type)
}
}
else if (type == DT_SECTOR_SOUND) // Plane as emitter
{
{
dint index = deltaId;
if (!(sector = map.sectorPtr(index)))
{
Expand All @@ -98,7 +100,7 @@ void Cl_ReadSoundDelta(deltatype_t type)
{
dint index = deltaId;

LOG_NET_XVERBOSE("DT_POLY_SOUND: poly=%d") << index;
LOG_NET_XVERBOSE("DT_POLY_SOUND: poly=%d", index);

if (!(emitter = (mobj_t *) (poly = map.polyobjPtr(index))))
{
Expand Down Expand Up @@ -246,7 +248,7 @@ void Cl_Sound()
return;
}

LOGDEV_NET_XVERBOSE("id %i") << sound;
LOGDEV_NET_XVERBOSE("id %i", sound);

dint volume = 127;
if (flags & SNDF_VOLUME)
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/client/clientsubsector.cpp
Expand Up @@ -40,6 +40,8 @@
#include "misc/face.h"
#include "dd_main.h" // verbose

#include <de/LogBuffer>

#include <QtAlgorithms>
#include <QHash>
#include <QMap>
Expand Down
4 changes: 3 additions & 1 deletion doomsday/apps/client/src/client/clplanemover.cpp
Expand Up @@ -28,6 +28,8 @@
#include "world/p_players.h"
#include "Sector"

#include <de/LogBuffer>

using namespace de;

thinker_s *ClPlaneMover::newThinker(Plane &plane, coord_t dest, float speed) // static
Expand All @@ -38,7 +40,7 @@ thinker_s *ClPlaneMover::newThinker(Plane &plane, coord_t dest, float speed) //
// Add to the map.
thinker_s *ptr = th.take();
plane.map().thinkers().add(*ptr, false /* not public */);
LOGDEV_MAP_XVERBOSE("New mover %p") << ptr;
LOGDEV_MAP_XVERBOSE("New mover %p", ptr);

// Immediate move?
if (fequal(speed, 0))
Expand Down
10 changes: 5 additions & 5 deletions doomsday/apps/client/src/client/clpolymover.cpp
Expand Up @@ -28,6 +28,8 @@
#include "world/thinkers.h"
#include "world/polyobjdata.h"

#include <de/LogBuffer>

using namespace de;

thinker_s *ClPolyMover::newThinker(Polyobj &polyobj, bool moving, bool rotating) // static
Expand All @@ -46,9 +48,7 @@ thinker_s *ClPolyMover::newThinker(Polyobj &polyobj, bool moving, bool rotating)
thinker_s *ptr = th.take();
polyobj.map().thinkers().add(*ptr, false /*not public*/);

LOGDEV_MAP_XVERBOSE("New polymover %p for polyobj #%i.")
<< ptr
<< polyobj.indexInMap();
LOGDEV_MAP_XVERBOSE("New polymover %p for polyobj #%i.", ptr << polyobj.indexInMap());

return ptr;
}
Expand Down Expand Up @@ -103,8 +103,8 @@ void ClPolyMover::think()
// /* && po->destAngle != -1*/) || !po->angleSpeed)
if (!po->angleSpeed || ABS(dist >> 2) <= ABS(speed >> 2))
{
LOGDEV_MAP_XVERBOSE("Mover %p reached end of turn, destAngle=%i")
<< &thinker() << po->destAngle;
LOGDEV_MAP_XVERBOSE("Mover %p reached end of turn, destAngle=%i",
&thinker() << po->destAngle);

// We'll arrive at the destination.
_rotate = false;
Expand Down
5 changes: 3 additions & 2 deletions doomsday/apps/client/src/dd_loop.cpp
Expand Up @@ -22,6 +22,7 @@

#include <de/timer.h>
#include <de/App>
#include <de/LogBuffer>
#ifdef __SERVER__
# include <de/TextApp>
#endif
Expand Down Expand Up @@ -271,8 +272,8 @@ static void advanceTime(timespan_t delta)
// case, we will adjust gameTime slightly so that it syncs again.
if(oldGameTic == SECONDS_TO_TICKS(::gameTime))
{
LOGDEV_XVERBOSE("Syncing gameTime with sharp ticks (tic=%i pos=%f)")
<< oldGameTic << ::frameTimePos;
LOGDEV_XVERBOSE("Syncing gameTime with sharp ticks (tic=%i pos=%f)",
oldGameTic << ::frameTimePos);

// Realign.
::gameTime = (SECONDS_TO_TICKS(::gameTime) + 1) / 35.f;
Expand Down
5 changes: 3 additions & 2 deletions doomsday/apps/client/src/gl/gl_main.cpp
Expand Up @@ -35,6 +35,7 @@
#include <de/DisplayMode>
#include <de/GLInfo>
#include <de/GLState>
#include <de/LogBuffer>
#include <doomsday/console/cmd.h>
#include <doomsday/console/var.h>
#include <doomsday/defs/mapinfo.h>
Expand Down Expand Up @@ -728,8 +729,8 @@ static void uploadContentUnmanaged(texturecontent_t const &content)
if(uploadMethod == gl::Immediate)
{
LOGDEV_GL_XVERBOSE("Uploading texture (%i:%ix%i) while not busy! "
"Should have been precached in busy mode?")
<< content.name << content.width << content.height;
"Should have been precached in busy mode?",
content.name << content.width << content.height);
}

GL_UploadTextureContent(content, uploadMethod);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/network/base/masterserver.cpp
Expand Up @@ -22,7 +22,7 @@

#include <QNetworkAccessManager>
#include <de/Config>
#include <de/Log>
#include <de/LogBuffer>
#include <de/shell/ServerInfo>
#include <de/data/json.h>
#include <de/memory.h>
Expand Down Expand Up @@ -175,7 +175,7 @@ void MasterWorker::requestFinished(QNetworkReply* reply)

if (reply->error() == QNetworkReply::NoError)
{
LOG_NET_XVERBOSE("Got reply");
LOG_NET_XVERBOSE("Got reply", "");

if (d->currentAction == REQUEST_SERVERS)
{
Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/client/src/render/fx/colorfilter.cpp
Expand Up @@ -22,6 +22,7 @@
#include "gl/gl_draw.h"

#include <de/GLInfo>
#include <de/LogBuffer>

using namespace de;

Expand All @@ -47,7 +48,7 @@ DENG_EXTERN_C void GL_SetFilterColor(float r, float g, float b, float a)
filterColor = newColorClamped;

LOG_AS("GL_SetFilterColor");
LOGDEV_GL_XVERBOSE("%s") << filterColor.asText();
LOGDEV_GL_XVERBOSE("%s", filterColor.asText());
}
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/render/fx/lensflares.cpp
Expand Up @@ -30,7 +30,7 @@
#include <de/Drawable>
#include <de/FileSystem>
#include <de/KdTreeAtlasAllocator>
#include <de/Log>
#include <de/LogBuffer>
#include <de/Range>
#include <de/Shared>

Expand Down Expand Up @@ -98,7 +98,7 @@ struct FlareData
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LOGDEV_GL_XVERBOSE("Releasing shared data");
LOGDEV_GL_XVERBOSE("Releasing shared data", "");
}

Image const &flareImage(String const &name)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/resource/bitmapfont.cpp
Expand Up @@ -24,7 +24,7 @@
#include "sys_system.h" // novideo
#include "FontManifest"
#include <doomsday/uri.h>
#include <de/Log>
#include <de/LogBuffer>
#include <de/mathutil.h> // M_CeilPow2()
#include <de/memory.h>
#include <doomsday/busymode.h>
Expand Down Expand Up @@ -319,8 +319,8 @@ void BitmapFont::glInit()
// Upload the texture.
if(!novideo && !isDedicated)
{
LOG_GL_XVERBOSE("Uploading atlas texture for \"%s\"...")
<< manifest().composeUri();
LOG_GL_XVERBOSE("Uploading atlas texture for \"%s\"...",
manifest().composeUri());

d->texGLName = GL_NewTextureWithParams(DGL_RGBA, d->texDimensions.x, d->texDimensions.y,
pixels, 0, 0, GL_LINEAR, GL_NEAREST, 0 /* no AF */,
Expand Down

0 comments on commit 1986306

Please sign in to comment.