On Thu, 21 Apr 2011 19:08:38 +0400, so <s...@so.com> wrote:
On Thu, 21 Apr 2011 15:37:42 +0300, Denis Koroskin <2kor...@gmail.com>
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");
So you want the iostream way, global logger objects, otherwise i don't
see how this solves the problem you are suggesting.
No globals, of course, loggers are part of objects. In most cases,
everyone who adds log entry creates its own logger and add it into a
hierarchy.