https://github.com/gkbrk/bunnylog-py
Parse BunnyCDN log files with Python
https://github.com/gkbrk/bunnylog-py
bunnycdn cdn log parser
Last synced: over 1 year ago
JSON representation
Parse BunnyCDN log files with Python
- Host: GitHub
- URL: https://github.com/gkbrk/bunnylog-py
- Owner: gkbrk
- License: mpl-2.0
- Created: 2019-06-13T22:31:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-13T22:38:08.000Z (about 7 years ago)
- Last Synced: 2025-03-02T00:37:35.304Z (over 1 year ago)
- Topics: bunnycdn, cdn, log, parser
- Language: Python
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
- [NAME](#NAME)
- [SYNOPSIS](#SYNOPSIS)
- [DESCRIPTION](#DESCRIPTION)
- [MODEL](#MODEL)
- [LogEntry](#LogEntry)
- [INTERFACE](#INTERFACE)
- [parse\_line](#parse_line)
# NAME
bunnylog - Python module to parse BunnyCDN log files
# SYNOPSIS
```
import bunnylog
bw = 0
with open('server.log') as logfile:
for line in logfile:
log = bunnylog.parse_line(line)
bw += log.length
print(f"Used {bw} bytes of bandwidth")
```
# DESCRIPTION
This module aims to parse the log files generated by BunnyCDN. You can
then take these and input them to your database or convert them to other
log formats.
# MODEL
## LogEntry
This module parses the log entries into *LogEntry* objects. Each object
has the following values.
- **hit** - *bool*
This value indicates if a request was a cache hit
- **status\_code** - *int*
The status code returned by the server
- **timestamp** - *int*
The timestamp of the request
- **length** - *int*
The length of the response in bytes
- **pull\_server** - *str*
The ID of the pull server on BunnyCDN
- **ip** - *str*
The IP address of the visitor
- **referrer** - *str*
The referrer page, indicated by the referer header
- **url** - *str*
The URL for the request
- **cdn\_country** - *str*
The country code for the CDN node that served this request
- **user\_agent** - *str*
The User-Agent header of the request
- **content\_hash** - *str*
The hash of the content that was sent to the client
- **visitor\_country** - *str*
The country code of the visitor
# INTERFACE
## parse\_line
Takes a log line as a string and returns a parsed LogEntry.