logatorBuild your own log parser | |
Download |
logator Ranking & Summary
Advertisement
- License:
- MIT/X Consortium Lic...
- Price:
- FREE
- Publisher Name:
- Mathieu Lecarme
- Publisher web site:
- http://garambrogne.net
logator Tags
logator Description
logator is a tool that allows you to build your own log parser.Installing itpython setup.py buildsudo python setup.py installUsing itYou need a source. Something wich iterate log line. The simplest way is STDIN and files, but you can also use syslogd protocol or more complex source.For reading loglines, you need a reader. Reader is basically a regex with simple string manipulations. You can add dynamic getter for castly query (ip to country for example). Dynamic attributes are lazy loaded and memoized.Query is done with filter, wich can be piped.Result can be return as dict wich can be easily serialized if you wont to index it or storing it.from logator.log import logfrom logator.weblog import Common, UserAgent, HostByName, Filter_by_code, Filter_by_attribute#The filterfiltr = Filter_by_code(200) | Filter_by_attribute('command', 'GET')#The sourcelogs = open('/var/log/apache2/access.log', 'r')#Lighttpd is the reader with two dynamic attributes reader : UserAgent, HostByNamefor line in filtr.filter(logs, Lighttpd, UserAgent, HostByName): print line.as_dict()User Agent parsing is stolen from Google code: http://code.google.com/p/ua-parser/.Product's homepage
logator Related Software