Qmmslog
a port of log4j to Qt
Copyright (C) 2001 Max M. Strumia. All rights reserved.
This software is published under the terms of the Gnu General Public License (GPL), the Apache Software License, and the Q Public License (QPL), copies of which are included with this distribution in ./licenses.
Introduction
This is a port to Qt/C++ of the Jakarta project's log4j package.
It is an attempt to bring the flexibility of log4j to a multi-platform C++ environment.
If you are unfamiliar with log4j, I quote here from the log4j
- documentation
-
Inserting log statements into your code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications.
On the other hand, some people argue that log statements pollute source code and decrease legibility. (We believe that the contrary is true).
With log4j it is possible to enable logging at runtime without modifying the application binary. The log4j package is designed so that these statements can remain in shipped code without incurring a heavy performance cost. Logging behavior can be controlled by editing a configuration file, without touching the application binary.
Logging equips the developer with <i>detailed context</i> for application failures. On the other hand, testing provides quality assurance and confidence in the application. Logging and testing should not be confused. They are complementary. When logging is wisely used, it can prove to be an essential tool.
One of the distinctive features of log4j is the notion of <i>inheritance</i> in loggers. Using a logger <em>hierarchy</em> it is possible to control which log statements are output at arbitrarily fine granularity but also great ease. This helps reduce the volume of logged output and minimize the cost of logging.
Requirements
Qmmslog now supports both the standard (non-threaded) version of Qt as well as the threaded version. That is, One can link against either -lqt or -lqt-mt.
I have tested this package on Gnu/Linux using egcs-2.91.66.
Installation
Typically, one unpacks the tarball in a suitable location using
tar xvzf qmmslog.tar.gz
Since this is alpha software (for now) I provide a Makefile suitable for use under GNU/Linux only. I have not made a .pro (for use with qmake), but will soon (or perhaps you might like to contribute?).
I have kept the Makefile as simple and uncryptic as possible with the intention that one can easily modify it to suit. One should only have to edit a few indicated lines at the top. With this out of the way, do the following:
cd src
make all
make install
This will compile, create libqmmslog.so, install the .so and all the includes to /usr/local/lib and /usr/local/include respectively, and invoke doxygen to generate documentation. The install step uses sudo, so you need to have the appropriate entry in /etc/sudoers. I am also assuming that /usr/local/lib is in either /etc/ld.so.conf or LD_LDBRARY_PATH.
Examine main.cpp to see how to use the package. Generally, one need only do the following:
#include <qmms/log.hh>
using namespace Qmms::Log;
(Note that I use *.hh and not *.h for include files.)
You can mail <a href="mailto:cromalloy@yahoo.com">me</a> with questions/comments/rants/flames/money.
Naming Convention
If the original package is log4j, and existing ports of it have already taken the names log4cpp, log4cplus, log4Py, log4Perl, etc., then why have I used qmmslog instead of log4qt?
Answer: Because I'm following
<a href="http://www.trolltech.com/developer/documentation/naming.html">
trolltech's naming convention</a>. Enough said.
Generating documentation manually
This step assumes that doxygen is installed on the user's system. I have included documentation (for those unfortunates who do not have doxygen yet), but note that the links to Qt classes will not work unless one runs the doxygen script installdox, as follows.
From the top-level directory of the distribution (not src!), simply type doxygen
to generate html, man, and latex docs. To activate links to Qt documentation, one must then do the following (after running doxygen):
cd docs/html
./installdox -l qt.tag@$QTDIR/doc/html
Change log
v. 0.1 - First release. Only links against qt-mt
v. 0.2 - Now links against either qt or qt-mt. Added internal logging mechanism
LogLog. Altered inheritance of some classes, added LayoutAppender
(new abstract base class for StreamAppender, SyslogAppender, and
QTextEditAppender)
v. 0.2.1 - Bugfixes. Several minor problems in 0.2 now fixed. Better Makefile
that should be easier for the user to modify.
| author: Max M. Strumia |
| mailto: cromalloy@yahoo.com |
