https://github.com/arusso/tgrep
https://github.com/arusso/tgrep
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/arusso/tgrep
- Owner: arusso
- Created: 2017-06-20T03:41:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-20T04:36:09.000Z (about 9 years ago)
- Last Synced: 2025-02-05T22:57:23.373Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
_In Febuary 2011, Reddit was looking to [hire some systems
engineers](https://www.reddit.com/r/blog/comments/fjgit/reddit_is_doubling_the_size_of_its_programming/),
and asked applicants to write a tool to search through web log files in a
specific format by date/time. This is my unfinished attempt to the backend
challenge._
## Project Requirements
1. Quickly search through log files. Example of log line (newlines added):
```
Feb 10 10:59:49 web03 haproxy[1631]: 10.350.42.161:58625 [10/Feb/2011:10:59:49.089] frontend
pool3/srv28-5020 0/138/0/19/160 200 488 - - ---- 332/332/13/0/0 0/15 {Mozilla/5.0 (Windows; U;
Windows NT 6.1; en-US; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7|www.reddit.com|
http://www.reddit.com/r/pics/?count=75&after=t3_fiic6|201.8.487.192|17.86.820.117|}
"POST /api/vote HTTP/1.1"
```
2. By default, it looks at /logs/haproxy.log -- if an argument is specified for
which file to open, it can be either appended or prepended to the time argument
3. Code must be leglible
### Given Details
* Each line starts with a date time
* Each log contains a single 24-hour period +- a few minutes
* Timestamps are always increasing in order
* You can ignore daylight savings
### Assumptions
* Time is in 24-hour notation (as was shown in the example: "tgrep 23:59-0:03")
## Approach
Attempt to do a binary search on the file, using the file size to estimate the
mid points used to reduce the search area by (theoretically) half.