Skip to content

Commit

Permalink
Client: Improved console output of various commands/subsystems
Browse files Browse the repository at this point in the history
Applied rich formatting and generally improved the console message
output.

Note that the monospace formatter doesn't handle tab stops presently…
  • Loading branch information
skyjake committed Jun 8, 2013
1 parent 4fcf0b6 commit ff47d82
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 186 deletions.
17 changes: 11 additions & 6 deletions doomsday/client/src/audio/audiodriver.cpp
Expand Up @@ -415,22 +415,27 @@ static void selectInterfaces(audiodriverid_t defaultDriverId)

void AudioDriver_PrintInterfaces(void)
{
int i;
LOG_INFO(_E("b") "Audio configuration" _E(".") " (by decreasing priority):");

Con_Message("Audio configuration (by decreasing priority):");
for(i = MAX_AUDIO_INTERFACES - 1; i >= 0; --i)
de::String str;
QTextStream os(&str);

for(int i = MAX_AUDIO_INTERFACES - 1; i >= 0; --i)
{
audiointerface_t* a = &activeInterfaces[i];
if(a->type == AUDIO_IMUSIC || a->type == AUDIO_ICD)
{
Con_Message(" %-5s: %s", a->type == AUDIO_IMUSIC? "Music" : "CD",
Str_Text(AudioDriver_InterfaceName(a->i.any)));
os << _E("Ta") " " << (a->type == AUDIO_IMUSIC? "Music" : "CD") << ": "
<< _E("Tb") << Str_Text(AudioDriver_InterfaceName(a->i.any)) << "\n";
}
else if(a->type == AUDIO_ISFX)
{
Con_Message(" SFX : %s", Str_Text(AudioDriver_InterfaceName(a->i.sfx)));
os << _E("Ta") << " SFX: " << _E("Tb")
<< Str_Text(AudioDriver_InterfaceName(a->i.sfx)) << "\n";
}
}

LOG_MSG("%s") << str.rightStrip();
}

/*
Expand Down
105 changes: 45 additions & 60 deletions doomsday/client/src/con_data.cpp
Expand Up @@ -803,36 +803,40 @@ cvartype_t Con_GetVariableType(char const* path)
return var->type;
}

void Con_PrintCVar(cvar_t* var, const char* prefix)
void Con_PrintCVar(cvar_t* var, char const *prefix)
{
DENG_ASSERT(inited);

char equals = '=';
AutoStr* path;

if(!var) return;

char equals = '=';
if((var->flags & CVF_PROTECTED) || (var->flags & CVF_READ_ONLY))
equals = ':';

if(prefix)
Con_Printf("%s", prefix);
de::String str;
QTextStream os(&str);

if(prefix) os << prefix;

AutoStr* path = CVar_ComposePath(var);

os << _E("b") << Str_Text(path) << _E(".") << " " << equals << " " << _E(">");

path = CVar_ComposePath(var);
switch(var->type)
{
case CVT_BYTE: Con_Printf("%s %c %d", Str_Text(path), equals, CV_BYTE(var)); break;
case CVT_INT: Con_Printf("%s %c %d", Str_Text(path), equals, CV_INT(var)); break;
case CVT_FLOAT: Con_Printf("%s %c %g", Str_Text(path), equals, CV_FLOAT(var)); break;
case CVT_CHARPTR: Con_Printf("%s %c \"%s\"", Str_Text(path), equals, CV_CHARPTR(var)); break;
case CVT_BYTE: os << CV_BYTE(var); break;
case CVT_INT: os << CV_INT(var); break;
case CVT_FLOAT: os << CV_FLOAT(var); break;
case CVT_CHARPTR: os << "\"" << CV_CHARPTR(var) << "\""; break;
case CVT_URIPTR: {
AutoStr* valPath = (CV_URIPTR(var)? Uri_ToString(CV_URIPTR(var)) : NULL);
Con_Printf("%s %c \"%s\"", Str_Text(path), equals, (CV_URIPTR(var)? Str_Text(valPath) : ""));
os << "\"" << (CV_URIPTR(var)? Str_Text(valPath) : "") << "\"";
break; }

default: Con_Printf("%s (bad type!)", Str_Text(path)); break;
default:
DENG_ASSERT(false);
break;
}
Con_Printf("\n");
LOG_MSG("%s") << str;
}

void Con_AddCommand(ccmdtemplate_t const* ccmd)
Expand All @@ -845,13 +849,7 @@ void Con_AddCommand(ccmdtemplate_t const* ccmd)

if(!ccmd) return;

if(!ccmd->name)
Con_Error("Con_AddCommand: CCmd missing a name.");

/*#if _DEBUG
Con_Message("Con_AddCommand: '%s' \"%s\" (%i).", ccmd->name,
ccmd->argTemplate, ccmd->flags);
#endif*/
DENG_ASSERT(ccmd->name != 0);

// Decode the usage string if present.
if(ccmd->argTemplate != 0)
Expand Down Expand Up @@ -1440,48 +1438,34 @@ static int aproposPrinter(knownword_t const* word, void* matching)
// See if 'matching' is anywhere in the known word.
if(strcasestr(Str_Text(text), (const char*)matching))
{
int const maxLen = 80; //CBuffer_MaxLineLength(Con_HistoryBuffer());
int avail;
ddstring_t buf;
char const* wType[KNOWNWORDTYPE_COUNT] = {
"[cmd]", "[var]", "[alias]", "[game]"
"cmd ", "var ", "alias ", "game "
};

Str_Init(&buf);
Str_Appendf(&buf, "%7s ", wType[word->type]);
Str_Appendf(&buf, "%-25s", Str_Text(text));
de::String str;
QTextStream os(&str);

avail = maxLen - Str_Length(&buf) - 4;
if(avail > 0)
{
ddstring_t tmp; Str_Init(&tmp);

// Look for a short description.
if(word->type == WT_CCMD || word->type == WT_CVAR)
{
char const* desc = DH_GetString(DH_Find(Str_Text(text)), HST_DESCRIPTION);
if(desc)
{
Str_Set(&tmp, desc);
}
}
else if(word->type == WT_GAME)
{
Str_Set(&tmp, Str_Text(reinterpret_cast<de::Game*>(word->data)->title()));
}
os << _E("l") << wType[word->type]
<< _E("0") << _E("b") << Str_Text(text) << " " << _E("2") << _E(">");

// Truncate.
if(Str_Length(&tmp) > avail - 3)
// Look for a short description.
de::String tmp;
if(word->type == WT_CCMD || word->type == WT_CVAR)
{
char const* desc = DH_GetString(DH_Find(Str_Text(text)), HST_DESCRIPTION);
if(desc)
{
Str_Truncate(&tmp, avail);
Str_Append(&tmp, "...");
tmp = desc;
}
Str_Appendf(&buf, " %s", Str_Text(&tmp));
Str_Free(&tmp);
}
else if(word->type == WT_GAME)
{
tmp = Str_Text(reinterpret_cast<de::Game*>(word->data)->title());
}

os << tmp;

Con_Printf("%s\n", Str_Text(&buf));
Str_Free(&buf);
LOG_MSG("%s") << str;
}

return 0;
Expand Down Expand Up @@ -1608,9 +1592,10 @@ static int printKnownWordWorker(knownword_t const* word, void* parameters)
return 0; // Skip overloaded variants.

if((str = DH_GetString(DH_Find(ccmd->name), HST_DESCRIPTION)))
Con_FPrintf(CPF_LIGHT|CPF_YELLOW, " %s (%s)\n", ccmd->name, str);
LOG_MSG(_E("b") "%s " _E(">") _E("2") "%s")
<< ccmd->name << str;
else
Con_FPrintf(CPF_LIGHT|CPF_YELLOW, " %s\n", ccmd->name);
LOG_MSG(_E("b") "%s") << ccmd->name;
break; }

case WT_CVAR: {
Expand All @@ -1619,17 +1604,17 @@ static int printKnownWordWorker(knownword_t const* word, void* parameters)
if(cvar->flags & CVF_HIDE)
return 0; // Skip hidden variables.

Con_PrintCVar(cvar, " ");
Con_PrintCVar(cvar, "");
break; }

case WT_CALIAS: {
calias_t* cal = (calias_t*) word->data;
Con_FPrintf(CPF_LIGHT|CPF_YELLOW, " %s == %s\n", cal->name, cal->command);
LOG_MSG(_E("b") "%s" _E(".") " == " _E(">") "%s") << cal->name << cal->command;
break; }

case WT_GAME: {
de::Game* game = (de::Game*) word->data;
Con_FPrintf(CPF_LIGHT|CPF_BLUE, " %s\n", Str_Text(game->identityKey()));
LOG_MSG(_E("1") "%s") << Str_Text(game->identityKey());
break; }

default:
Expand Down
50 changes: 25 additions & 25 deletions doomsday/client/src/con_main.cpp
Expand Up @@ -1882,7 +1882,7 @@ void Con_PrintRuler(void)
{
*/

LogBuffer_Msg(DENG2_ESC("R") "\n");
LogBuffer_Msg(_E("R") "\n");

//}
}
Expand Down Expand Up @@ -2221,30 +2221,28 @@ D_CMD(Help)
#endif
*/

Con_PrintRuler();
Con_FPrintf(CPF_YELLOW | CPF_CENTER, "-=- " DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT " Console -=-\n");
//Con_PrintRuler();

LOG_MSG(_E("1") DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT " Console");

#define COLUMN(A, B) "\n" _E("Ta") _E("b") " " << A << " " _E(".") _E("Tb") << B

#ifdef __CLIENT__
Con_Printf("Keys:\n");
//Con_Printf("%-14s Open/close the console.\n", actKeyName);
//Con_Printf("Alt-%-10s Switch between half and full screen mode.\n", actKeyName);
Con_Printf("F5 Clear the buffer.\n");
Con_Printf("Alt-C Clear the command line.\n");
Con_Printf("Insert Switch between replace and insert modes.\n");
Con_Printf("Shift-Left Move cursor to the start of the command line.\n");
Con_Printf("Shift-Right Move cursor to the end of the command line.\n");
Con_Printf("Shift-PgUp/Dn Move console window up/down.\n");
Con_Printf("Home Jump to the beginning of the buffer.\n");
Con_Printf("End Jump to the end of the buffer.\n");
Con_Printf("PageUp/Down Scroll up/down a couple of lines.\n");
Con_Printf("\n");
LOG_MSG(_E("D") "Keys:" _E("."))
<< COLUMN("Esc", "Open/close the taskbar")
<< COLUMN("Shift-Esc", "Open the console")
<< COLUMN("F5", "Clear the console message history")
<< COLUMN("Home", "Jump to beginning of line")
<< COLUMN("End", "Jump to end of line")
<< COLUMN("PageUp/Down", "Scroll up/down in the history, or expand the history to full height")
<< COLUMN("Shift-PgUp/Dn", "Jump to the top/bottom of the history");
#endif
Con_Printf("Getting started:\n");
Con_Printf("Enter \"help (what)\" for information about (what).\n");
Con_Printf("Enter \"listcmds\" to list available commands.\n");
Con_Printf("Enter \"listgames\" to list installed games and their status.\n");
Con_Printf("Enter \"listvars\" to list available variables.\n");
Con_PrintRuler();
LOG_MSG(_E("D") "Getting started:");
LOG_MSG(" " _E(">") "Enter " _E("b") "help (what)" _E(".") " for information about " _E("l") "(what)");
LOG_MSG(" " _E(">") "Enter " _E("b") "listcmds" _E(".") " to list available commands");
LOG_MSG(" " _E(">") "Enter " _E("b") "listgames" _E(".") " to list installed games and their status");
LOG_MSG(" " _E(">") "Enter " _E("b") "listvars" _E(".") " to list available variables");
//Con_PrintRuler();
return true;
}

Expand All @@ -2270,9 +2268,11 @@ D_CMD(Version)
//Con_Printf("Homepage: %s\n", DOOMSDAY_HOMEURL);
//Con_Printf("Project homepage: %s\n", DENGPROJECT_HOMEURL);

LOG_MSG(DENG2_ESC("D") DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_FULLTEXT
DENG2_ESC("0") "\nHomepage: " DENG2_ESC("i") DOOMSDAY_HOMEURL
DENG2_ESC(".") "\nProject homepage: " DENG2_ESC("i") DENGPROJECT_HOMEURL);
LOG_MSG(_E("D") DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_FULLTEXT);
LOG_MSG("Homepage: "
_E("\t") _E("i") DOOMSDAY_HOMEURL
_E(".") _E(".") "\nProject homepage: "
_E("\t") _E("i") DENGPROJECT_HOMEURL);

// Print the version info of the current game if loaded.
if(App_GameLoaded())
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_main.cpp
Expand Up @@ -2828,7 +2828,7 @@ static de::File1* tryLoadFile(de::Uri const& search, size_t baseOffset)
if(App_FileSystem().accessFile(search))
{
// Must already be loaded.
LOG_VERBOSE("\"%s\" already loaded.") << NativePath(search.asText()).pretty();
LOG_DEBUG("\"%s\" already loaded.") << NativePath(search.asText()).pretty();
}
}
return 0;
Expand Down
57 changes: 31 additions & 26 deletions doomsday/client/src/def_main.cpp
Expand Up @@ -25,6 +25,7 @@
#include <ctype.h>

#include <de/NativePath>
#include <QTextStream>

#include "de_base.h"
#include "de_system.h"
Expand Down Expand Up @@ -728,12 +729,12 @@ void Def_ReadProcessDED(char const* path)
/**
* Prints a count with a 2-space indentation.
*/
void Def_CountMsg(int count, const char* label)
static de::String defCountMsg(int count, de::String const &label)
{
if(!verbose && !count)
return; // Don't print zeros if not verbose.
return ""; // Don't print zeros if not verbose.

Con_Message("%5i %s", count, label);
return de::String(_E("Ta") " %1 " _E("Tb") "%2\n").arg(count).arg(label);
}

/**
Expand Down Expand Up @@ -1771,36 +1772,40 @@ void Def_Read()
}

// Log a summary of the definition database.
Con_Message("Definitions:");
Def_CountMsg(defs.count.groups.num, "animation groups");
Def_CountMsg(defs.count.compositeFonts.num, "composite fonts");
Def_CountMsg(defs.count.details.num, "detail textures");
Def_CountMsg(defs.count.finales.num, "finales");
Def_CountMsg(defs.count.lights.num, "lights");
Def_CountMsg(defs.count.lineTypes.num, "line types");
Def_CountMsg(defs.count.mapInfo.num, "map infos");
LOG_MSG(_E("b") "Definitions:");
de::String str;
QTextStream os(&str);
os << defCountMsg(defs.count.groups.num, "animation groups");
os << defCountMsg(defs.count.compositeFonts.num, "composite fonts");
os << defCountMsg(defs.count.details.num, "detail textures");
os << defCountMsg(defs.count.finales.num, "finales");
os << defCountMsg(defs.count.lights.num, "lights");
os << defCountMsg(defs.count.lineTypes.num, "line types");
os << defCountMsg(defs.count.mapInfo.num, "map infos");

int nonAutoGeneratedCount = 0;
for(int i = 0; i < defs.count.materials.num; ++i)
{
if(!defs.materials[i].autoGenerated)
++nonAutoGeneratedCount;
}
Def_CountMsg(nonAutoGeneratedCount, "materials");

Def_CountMsg(defs.models.size(), "models");
Def_CountMsg(defs.count.ptcGens.num, "particle generators");
Def_CountMsg(defs.count.skies.num, "skies");
Def_CountMsg(defs.count.sectorTypes.num, "sector types");
Def_CountMsg(defs.count.music.num, "songs");
Def_CountMsg(countSounds.num, "sound effects");
Def_CountMsg(countSprNames.num, "sprite names");
Def_CountMsg(countStates.num, "states");
Def_CountMsg(defs.count.decorations.num, "surface decorations");
Def_CountMsg(defs.count.reflections.num, "surface reflections");
Def_CountMsg(countTexts.num, "text strings");
Def_CountMsg(defs.count.textureEnv.num, "texture environments");
Def_CountMsg(countMobjInfo.num, "things");
os << defCountMsg(nonAutoGeneratedCount, "materials");

os << defCountMsg(defs.models.size(), "models");
os << defCountMsg(defs.count.ptcGens.num, "particle generators");
os << defCountMsg(defs.count.skies.num, "skies");
os << defCountMsg(defs.count.sectorTypes.num, "sector types");
os << defCountMsg(defs.count.music.num, "songs");
os << defCountMsg(countSounds.num, "sound effects");
os << defCountMsg(countSprNames.num, "sprite names");
os << defCountMsg(countStates.num, "states");
os << defCountMsg(defs.count.decorations.num, "surface decorations");
os << defCountMsg(defs.count.reflections.num, "surface reflections");
os << defCountMsg(countTexts.num, "text strings");
os << defCountMsg(defs.count.textureEnv.num, "texture environments");
os << defCountMsg(countMobjInfo.num, "things");

LOG_MSG("%s") << str.rightStrip();

defsInited = true;
}
Expand Down
7 changes: 3 additions & 4 deletions doomsday/client/src/filesys/filehandle.cpp
Expand Up @@ -136,10 +136,9 @@ FileHandle* FileHandleBuilder::fromLump(File1& lump, bool dontBuffer)
hndl->d->pos = hndl->d->data = (uint8_t*) M_Malloc(hndl->d->size);
if(!hndl->d->data) Con_Error("FileHandleBuilder::fromFileLump: Failed on allocation of %lu bytes for data buffer.", (unsigned long) hndl->d->size);

#if _DEBUG
LOG_VERBOSE("[%p] Buffering \"%s:%s\"...")
<< dintptr(hndl) << NativePath(lump.container().composePath()).pretty() << NativePath(lump.composePath()).pretty();
#endif
LOG_DEV_TRACE("[%p] Buffering \"%s:%s\"...",
dintptr(hndl) << NativePath(lump.container().composePath()).pretty() << NativePath(lump.composePath()).pretty());

lump.read((uint8_t*)hndl->d->data, 0, lump.size());
}
return hndl;
Expand Down

0 comments on commit ff47d82

Please sign in to comment.