Log¶
Writes to the host log, %LOCALAPPDATA%\Ballest\Saved\PluginManager\host.log. It's recreated each time the game
starts and is the first place to look when a plugin misbehaves. Every line is tagged with the plugin's id.
Info¶
void Log::Info(const string &in)
Writes an information line to the host log.
Example
// Shows up in host.log as "[info] [my-plugin] loaded, 3 tracks remembered"
Log::Info("loaded, " + trackCount + " tracks remembered");
Warn¶
void Log::Warn(const string &in)
Writes a warning line to the host log. Use it for something that went wrong but that the plugin can carry on from.
Example
// A saved value that can't be read: warn and fall back to the default
if (parseFloat(saved) <= 0)
Log::Warn("saved size '" + saved + "' is not a size; using 56");
Error¶
void Log::Error(const string &in)
Writes an error line to the host log. The plugin keeps running; this only records the problem.
Example
// Something the player should report
Log::Error("could not find the timer window after a map change");
LineCount¶
uint Log::LineCount()
How many lines have been written to the log this session, by the host and every plugin. Use it with
Log::Line to show the log inside the game.
Example
// Only rebuild a log view when something new was written
uint count = Log::LineCount();
if (count != shownLines)
{
RebuildLogView();
shownLines = count;
}
Line¶
string Log::Line(uint)
One line of this session's log, numbered from 0. Only the most recent lines are kept in memory. An older line comes
back as "".
Example
// The last 20 lines, oldest first
string text;
uint count = Log::LineCount();
for (uint i = count > 20 ? count - 20 : 0; i < count; i++)
text += Log::Line(i) + "\n";
logArea.text = text;