|Perl Monk, Perl Meditation|
I'd love to use constants instead of 0/1/2, but since I'm doing configuration during import, the constants wouldn't be available during the configuration. I could accept string values, something like:
In this particular case, I don't think the 0/1/2 division is all that unintuitive. At its core, it's boolean: should I log warnings? yes=>1, no=>0. I admit the '2' is more of a stretch, but considering any mode set to 2 logs to 2 places (STDERR and logfile), I don't think it's very far-fetched. So, I'm undecided about that one.
Your other suggestions are all good, but they suggest, to me, that you'd want one of the already-existing log modules rather than this one.
For syslog-style logging, if you need or want that, you're better off with one of the existing log modules anyhow (like Sys::Syslog or the mother of them all, Log::Log4Perl), so I'm not sure it's worth the work to implement properly.
The globals suggestion is interesting, but I'm worried about a functionality trade. One of the original reasons for the decision I made was to easily allow configuration of logging for the entire application in one place. I can see the argument for letting modules log differently, but I can't grok how to do that while still allowing the choice of how it works today. That is, all modules simply use Log, and the calling program does the configuration.
Besides, when I need that level of control, I'm probably already in the realm of wanting all that Log::Log4Perl provides anyhow, so I'd move to that point. Unless I'm missing something? I'd be open to suggestions on how I could have it both ways, in which case it would go on my todo list.
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet
In reply to Re^2: RFC: A simple and badly-named logging module