Show HN: Logparser – Alternative to GoAccess Written in Python
github.com
github.com
It seems to use a library clfparser to parse apache common log format logs; internally that uses Python's regex engine which is written in C.
6000 line/s seems incredibly slow to me for a C program parsing a log file. I'm seeing a lot or strstr's, strlen's, strdup's, and strchr's in GoAccess's parse.c, all of which are O(n) per line and, while fine in isolation, could be causing GoAccess to do quite a bit more work per line than just using an optimized regex engine.
All rights reserved.
Copyright (c) 2020 Lucian Marin
It was the MIT license at the time of initial commit, and been updated to this. So it's not immediately clear if anyone else can necessarily use Logparser - care to clarify, Lucian?This is hard the first time you do it, but worth learning because it's a really great way to distribute your Python software.
I'm giving a talk about how to do this at PyGotham next month, but the notes from that talk are already available and may be useful to you: https://github.com/simonw/pygotham-packaging
You may also find this cookiecutter template that I use to build and package Python CLI apps helpful: https://github.com/simonw/click-app
There is no true “close source” for pure Python programs, but if obfuscation is close enough, you can choose to only deploy wheels containing pre-compiled pyc files. This is good enough for most situations.
If you want to support pulling info out of common logs it's pretty simple to pull together a list of regexes for the default log format in each major system. Simple example here: https://github.com/multiprocessio/datastation/blob/master/sh....
I use this in the app to be able to quickly pull info out of access logs for further analysis a la OP's app and GoAccess but in a GUI where you can also do further processing.
Demo video of this here: https://www.youtube.com/watch?v=sCx2mF2jyUQ&t=9s.
https://github.com/logstash-plugins/logstash-patterns-core/t...
Currently if 4 clients hit one URL and 1 client hits 5 logparser will register 5 records in each category (unless they're classified as bots for browsers and systems). With a Counter, it'd be 9.
Both informations could be accessible using a `defaultdict(Counter)` but I don't know how useful that would be to the people actually using logparser.