Logger for D
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Aug 27 19:33:43 PDT 2010
On 8/27/10 18:18 PDT, sybrandy wrote:
> Here's my current version of the logger. All of the documentation
> should be in the logger.d file. I also provided a sample config file
> (logger.conf) and a sample test file that I was using for benchmarking
> (main.d). Let me know if you have any questions. Feedback on improving
> this is also welcome.
>
> The one thing I forgot to note in here is that the function that writes
> to the log is passed into the second version of the constructor, which
> needs to be used only once in the code. A simple log writer is included
> at the bottom of logger.d that does work. The reason I did this was
> when I initially asked for feedback, I got several ideas on how the
> logger can be improved. Also, I discussed this with a friend of mine
> who stated that people may want to log to something other than a file,
> such as syslog. So, instead of trying to make the one "end all be all"
> logger, I felt that by allowing it to accept a function as a parameter
> to the constructor, the person can write to any type of log file,
> database, whatever they want and the logger interface works the same no
> matter what.
>
> There currently is a bug somewhere that I don't understand. Even though
> I have "OwnerTerminated" as part of my receive statement, I still see
> exceptions when the program closes. However, it doesn't seem to affect
> the execution of the logger.
>
> Enjoy.
>
> Casey
Thanks. I think we should establish a tradition for reviews on this
forum. The Boost review model has functioned very well, in the sense
that it has consistently produced two outcomes: excellent libraries and
pulp-beaten library authors. So I'd opt if at all possible for a tough
review process that produces good libraries as opposed to a nicey-nicey
process that fosters a low barrier of entry.
As I guess you suspected already, I have a few critical comments about
the proposed libraries. In brief, the library as proposed:
* does stuff that I don't care about (creation of logs, pluggable
writers, overridable logging functions);
* does not do the two fundamental things that all loggers should do.
Those only two things are:
1. Configure logging level during compilation
2. Configure logging level during runtime
If you want to have your library accepted in Phobos, I suggest you take
a very close look at glog's interface and implementation. It's a simple
and robust library used by two major companies that depend on good
logging. To exaggerate a bit, "so"s seat-of-the pants sample code is
closer to the ideal logging library than your current draft. But I am
encouraged by the fact that you went through the aggravation to write
the code and show it to everybody, so hopefully you'll have the
willpower to push this through.
Thanks,
Andrei
More information about the Digitalmars-d
mailing list