On 2011-04-21 14:37, Denis Koroskin wrote:
On Thu, 21 Apr 2011 01:34:29 +0400, so <s...@so.com> wrote:

For me, Logger needs to be simple but feature complete. Here is my
ideal syntax:

Logger log = new Logger();
log.warn("bewarned");
log.error("error code: %d", 42);
log.fatal("Derp");

Fine if you remove the first line, switching the output is something
we rarely do, so we shouldn't mandate this for each use.

note("just a note :", 5);
note!warn("bewarned");
note!error(c, ", ", d);

Having different loggers for different parts of programs (e.g. separate
logger for my rendering, separate one for audio, separate for physics,
and so on) is a must for me.
Because when you debug your code by analyzing log output, you want to be
able to filter out non-relevant stuff. If you only have ONE logger, you
will start adding stupid prefixes like this:

error("GAME/GAMEMODE_CHALLENGE/OBJECTIVE_CHECKER: match data frame is
not valid");

instead of

log.error("match data frame is not valid");

"log" could be a default instance of a class or struct (Logger for example), instead of a function, implementing opCall. Then you could use it like this:

log("info message or whatever is the default");
log.error("error message"); // and so on

auto gameLog = new Logger;
// set custom settings for the game logging
gameLog("info message");

--
/Jacob Carlborg

Reply via email to