A Remote Rotating Log for Python that works instantly
Download from Github | Sourceforge | see Change History
rrlog is a pure Python logging tool. It is for both debugging and production and provides common features instantly. These are:
How it looks like, for the impatient
A rotating server to log over sockets looks like:
logServer = filewriter.createRotatingServer(
filePathPattern = "./myfile-%s.log",
rotateCount=3,
rotateLineMin=10,
)
socketserver.startServer(logServer)
and an application using that server:
log = socketclient.createClientLog(
errorHandler="stderr",
)
log("Hello")
See below for full examples.
Most battery types included
Everything works instantly. No additional libraries required, except for database logging. Database logging needs the SqlAlchemy package.
Where it sucks
There are at least the following caveats:
Major improvements likely to come next are:
There are multiple conventient create() functions. Each makes a specific log configuration: for local or remote logging, into a file or a database etc. Look into the Basic Examples to see which create...() functions are available.
You got a log object. Call it with these arguments:
Example:
log("Uuups!","E")
Althought that log object is ready to use, you can Use Pythons standard logging. (The log integrates as a handler.)
There are more arguments. See Basic Examples or the rrlog.Log.__call__() docstring.
Categories are custom. They fit specific needs. However there is a convention: “E” for error messages, “W” for warnings.
The category latter appears in each logged line (leftmost, by default).
Example use of the category: Messages with category “U” could trace the user behaviour of your website. By extracting all logfile lines that start with “U ”, you get a log essence with the user behaviour. rrlog can also Send mails for selected categories. For example, “S” could mark Security relevant messages which automatically trigger emails. Or, with every text a user typed into the contact formular, we log with category “M” and the user message as content. The rrlog can immediately send an email with the logged content.
Now for something completely different ...
When using database logging, the SQLAlchemy library is required. File logging needs no additional library.
Tested environment:
Only this environment is tested. rrlog supports a wide range of Python and SQLAlchemy versions, to minimize dependency trouble. There’s a wide version range expected to work:
If some of these “supported versions” don’t work, it is considered a bug. Please tell (Contact)
Bug reports, improvements ...
Mail to rrlog at reifenberg.de
Or see http://www.reifenberg.de/rrlog/ or the sourceforge site Sourceforge
MIT License
Copyright (c) 2007 Ruben Reifenberg
This software contains code from other MIT licensed projects. Thanks to:
The simplejson package:
Copyright (c) 2006 Bob Ippolito
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.