On Fri, Oct 21, 2011 at 11:55 AM, Richard Huxton <dev@archonet.com> wrote:
At the moment, the logging levels are exposed directly (debug, warning, error). All the major logging modules seem to expose a single object (Log::Log4perl, Log::Dispatch, Log::Any etc). Doing similar would make logging more consistent across dancer and my non-web modules.
To be explicit, I'm suggesting this:
debug("current id = $id")
would become:
log->debug("current id = $id")
It's a purely cosmetic change at one level, but it does:
1. Reduce namespace pollution
2. Allow for alternative log-levels
Namespace pollution is - for good or bad - what Dancer is about; otherwise, there would be no DSL. I like the idea of having one-off functions for logging as for anything else, even if I like Log::Log4perl and I usually avoid Dancer's internal debugging. IMHO your proposal should go on the Plugin side (e.g. Dancer::Plugin::Log::Log4perl)
I actually think the printf-style functionality of Log::Any is worth stealing too. It lets you do things like:
log->debugf("user %d has fields %s", $user_id, $user_hashref)
With $user_hashref being automatically piped through Data::Dumper
I like the idea of the "-f", but this would probably bloat and pollute the namespace. Again... this would be a nice plugin :-)