Skip to main content

Simple Python library to use parse log files

Project description

Redparser

Redparser is a simple Python program that can parse a log based on command line arguments.

Usage

Run util.py as a Python script, passing the log file as the last argument to utilize the mmap library for fast searches or push the log file to memory for the util to read log file from stdin.

Example:

./util.py --last 10 --timestamps --ipv4 --ipv6 example.log

Outputs: Alt Text

The complete usage can be seen by using the -h flag.

usage: ./util.py [OPTION]... [FILE]
usage: cat [FILE] | ./util.py [OPTION]
usage: redparser [OPTION]... [FILE]
usage: cat [FILE] | redparser[OPTION]

Parse logs of various kinds

optional arguments:
  -h, --help            show this help message and exit
  -f, --first NUM       Print first NUM lines
  -l, --last NUM        Print last NUM lines
  -t, --timestamps      Print lines that contain a timestamp in HH:MM:SS format
  -i, --ipv4 IP         Print lines that contain an IPv4 address, matching IPs (Optional) highlighted
  -I, --ipv6 IP         Print lines that contain an IPv6 address, matching IPs (Optional) highlighted

Install with pip

pip install redparser

TODO

  • More readable highlighting of ip address
  • Refactor argparser to be more readable and use better data structures
  • More testing needs to be added
  • Should be able to check ip address from cmdline matches a line (easy fix)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redparser-1.0.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redparser-1.0.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file redparser-1.0.1.tar.gz.

File metadata

  • Download URL: redparser-1.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for redparser-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e8b90124dd3ecdb0d65878a193e601b112616be54204997c17fe52f75e64171a
MD5 480954ad8d93668491aa900e6ca98724
BLAKE2b-256 b76e4d16240f436699498a68d7a26d1e10142a73522e384ad07880faad91978a

See more details on using hashes here.

File details

Details for the file redparser-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: redparser-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for redparser-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b1b7cfbc990ea318566c6633c3795863aaa4a400d8dc964de23a40edbba8fd4
MD5 6b0b0f93b1569a22a84e97b4f8726dad
BLAKE2b-256 ed40148fe1e23b477f5cfed9c757413810f87c3529edb4809415ab48a16cc448

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page