Archive for January 10, 2006

I will shamelessly quote Mjac over on his blog

Fox News is the only remedy for a tedious school day. When I get home, I switch it on to find hilarious American presenters talking about nefarious events in a fixed and predictable fashion. Honestly, it is a cure for whatever ill you are feeling: the “fair and balanced” view expressed is ludicrous to the point of being entertaining.

I’m not sure how seriously anyone takes it – its not that Fox News doesn’t give good coverage (it does), its not that they’re purposely aiming to amuse (I’m sure they’re not…are they?) but to we poor serious minded people watching the channel does constitute amusement. I’m not sure exactly why – maybe its the announcement of the next Democrats filibuster threat arriving as if the end of the world were nigh, or the in-depth analysis of whether that guy in a white sedan fleeing the police is going to give up or make a dash for the freeway, or maybe its the number of “Fox News Contributors” and their way of smiling at each other (while hating each other’s guts so obviously in some cases).

Maybe this is what happens when News coverage is converted into high drama for the entertainment of the masses. Rock on Sky News…

Rollin’, Rollin’, Rollin’…

There has to be something under a LGPL or BSD somewhere, but if there is I can’t find it. After looking for a PHP logging library, the two most likely candidates are log4php and PEAR::Log. One is under the Apache License Version 2.0, the other under the PHP License. Neither is compatible with the GPL, and hence the AGPL.

The only BSD licensed Logger was to be found as part of eZ components. This however is specifically PHP5, with no support for PHP4. Waiting a year or two for more PHP5 penetration is not really an option I care for ;-).

All other alternatives I’ve found are either too simple, or too restrictive (and there’s a handful of those – none recent, or in procedural, or with php3 file extensions…)

Iamsure probably has it right that in these circumstances its probably necessary to go spend a while rolling your own implementation – so that’s what I’m about to start doing. So after a little thought I’ve decided to name it the Lugnar PHP Logging Library. Loggers are fairly simple – they do one thing, and do it well – so the time input should be minimal. I’ll release it under the LGPL, and stuff it into Q-LIB for use in Quantum Star SE.

Now the logger needs to do a few things. log4php does this very well, but it takes 26 includes to do it (which seems a bit much for a small application). Basically I want to:

a) be able to set a Layout for the log message, i.e. html, plaintext, xml, various text formats, or just a simple array.

b) be able to set an Appender, i.e. a class to handle writing to a resource: file, database, echo, trigger_error(), and even email.

c) to be capable of adding, removing information fields at will. For example I might want to add a user_id and IP to certain log events.

d) it should be capable of auto-generating objects based on prebuilt config files. Make setup a lot easier for more complex loggers. For example I may want a logger to log the same event as an ArrayLayout to the Database Appender, AND a SimpleLayout to the Email Appender – both at once.

e) it should (perhaps obviously) need to differentiate between log levels, and be capable of ignoring log events we’re not interested in. For example I could define a logger with a log level of WARN to ignore all levels except WARN, ERROR and FATAL, i.e. INFO and DEBUG log events would not be logged or reported.

Although loggers appear complex, what they do is extremely simple. They take a message, add additional information, format it, and write it to a resource. Not exactly rocket science – which may explain why there are so few PHP loggers (anyone can throw together a few lines to do the same thing). Unfortunately I really need a configurable library – not a limited one file class that can’t be used for complex logging.