- I wrote loggrok a while back as I needed a simple library
for analyzing logs. I am not actively developing loggrok, but please let me know if you find any bugs etc.
Features include:
Simple callback system (loggrok.actions)
Seemless iteration over multiple rollover-index based log files - smartly joins broken lines (RollingIndexLogStream)
Custom regex-based header and message body matching.
Example usage:
>>> from loggrok.actions import Action >>> action = Action() >>> def printError(entry): ... print 'err!', str(entry)[:-1] ... >>> action.addLevelCallback('ERROR', printError) >>> def printWarning(entry): ... print 'warning!', str(entry)[:-1] ... >>> action.addLevelCallback('WARN', printWarning) >>> from loggrok.log import LogStream >>> stream = LogStream(fname) >>> stream.action = action >>> for entry in stream: ... continue ... err! blah blah warning! blah blah err! blah blahYou can also write your own regexes for matching custom headers:
>>> from loggrok.parse import HeaderParser, MessageParser >>> header_patt = r'^([a-zA-Z]+) ([a-zA-Z]+) <(\d+)> ' # Entry attributes correspond to groups in regex pattern >>> header_attrs = ('foo', 'bar', 'baz') >>> header_parser = HeaderParser(header_patt, header_attrs) >>> message_patterns = (...) # regexs for message body - after header >>> message_attrs = (...) # tuple of attribute tuples corresponding to patters >>> messageParser = MessageParser(message_patterns, message_attrs) ... >>> stream.messageParser = messageParserSee doctest in tests directory for working examples.
To run unit tests:
python runtests.py
N.B. - loggrok will emit warning related to “broken” CurriedCallable class, though it should not cause issues.
Release files for loggrok 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| loggrok-0.2.1.tar.gz | 10.9 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| loggrok-0.2.1-py2.5.egg | Legacy Egg format | - | - | Details |
| loggrok-0.2.1-py2.4.egg | Legacy Egg format | - | - | Details |
Total release size: 36.3 kB
Release files / loggrok-0.2.1.tar.gz
| Download URL | loggrok-0.2.1.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a92bc52abda416db3389a7d4d00e45535e7fe9700adeb5e80f756a386e33f232
|
|
BLAKE2b-256 checksum How to use checksums |
7dccb118845b0110ed09fec8c77b7023cacc5dccb86332fb778ed03db9afaa36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / loggrok-0.2.1-py2.5.egg
| Download URL | loggrok-0.2.1-py2.5.egg |
|---|---|
| Size | 12.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
03a580644828d73bc448a08737439466b7f4e27ac79f0e5be75fc34b9526220f
|
|
BLAKE2b-256 checksum How to use checksums |
9ca0ee46273386655a240ae81a75f980599e0f935b50734bd8208ff57723defc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / loggrok-0.2.1-py2.4.egg
| Download URL | loggrok-0.2.1-py2.4.egg |
|---|---|
| Size | 12.7 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
6b38c085d77c27043600da2f78f9cf5bd5b7b9702bb6bf11b9f9c11dcdec5e35
|
|
BLAKE2b-256 checksum How to use checksums |
b5bc59e481fbbdab2bbb8e3a65b5c2cb740897a6e11f1bf07984acf1fb85d333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |