Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

fix bug with regex matching when using Python 3 #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apache_log_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
from datetime import datetime, tzinfo, timedelta
import sys

import user_agents

Expand Down Expand Up @@ -220,6 +221,8 @@ def __init__(self, format_string):
self.names = tuple(self.names)

def parse(self, log_line):
if (sys.version_info.major > 2):
log_line = log_line.decode('utf-8')
match = self.log_line_regex.match(log_line)
if match is None:
raise LineDoesntMatchException(log_line=log_line, regex=self.log_line_regex.pattern)
Expand Down