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 as 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 if 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.0.tar.gz (7.0 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.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: redparser-1.0.0.tar.gz
  • Upload date:
  • Size: 7.0 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.0.tar.gz
Algorithm Hash digest
SHA256 8017b84b8e011c45d8ff122d665338d0e0f9dd101ecca024084f032c0874a93f
MD5 d36068e5022ebd2377e9dd97046fef40
BLAKE2b-256 371dbb806f2a64749edfdbe3866c1c6431ab3d4e97fc59510624808289b97fbd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redparser-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8534a4684fe4add8ffeafd897e709ebd6e865e1bfb75fd67be4235655922ce38
MD5 220d276f1e28240db5758c05fc12f693
BLAKE2b-256 f9deb48f3e6b986448c90d6f507f39ee8a9779be99b3ccd4df1148f21e850e5f

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