Skip to main content

Perform a binary search through a log file to find a range of times and print the corresponding lines

Project description

timegrep.py by Dennis Williamson 20100113
in response to http://serverfault.com/questions/101744/fast-extraction-of-a-time-range-from-syslog-logfile
Improvements by Fabrice FACORAT 20110914

Perform a binary search through a log file to find a range of times
and print the corresponding lines
Supported Log Formats:
- W3C Extended: %Y-%m-%d %H:%M:%S
- Syslog: %b %d %H:%M:%S
- NSCA Common/Apache: host rfc931 username [%d/%b/%Y:%H:%M:%S +TZ]
- Bind8: %d-%b-%Y %H:%M:%S.
- Nginx Error logs: %Y/%m/%d %H:%M:%S.
Tested with Python 2.6

TODO: Make sure that it works if the seek falls in the middle of
the first or last line
TODO: Make sure it's not blind to a line where the sync read falls
exactly at the beginning of the line being searched for and
then gets skipped by the second read
DONE: Support more log time format
TODO: Support case when log files may not be properly sorted ( remove superfluous lines )
DONE: Support on the fly log format definition with --log-regexp

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

timegrep-1.5.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file timegrep-1.5.tar.gz.

File metadata

  • Download URL: timegrep-1.5.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for timegrep-1.5.tar.gz
Algorithm Hash digest
SHA256 b3659a9035333bfbd9250145464cc8b8eaa43c75571367353fe2e5258af7a504
MD5 89eb4f6b8a4b93084870b84a592f65ab
BLAKE2b-256 1e5298074f1e44231083c3b8ce487553b231eab213d7510fb5d4d00dd4169971

See more details on using hashes here.

Supported by

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