Skip to content

Commit

Permalink
Merge pull request #1 from scottwilliambeasley/scottwilliambeasley-pa…
Browse files Browse the repository at this point in the history
…tch-1

fix bug with regex matching when using Python 3+
  • Loading branch information
scottwilliambeasley authored Apr 8, 2018
2 parents 1e08f70 + b15a50a commit d02204a
Showing 1 changed file with 3 additions and 0 deletions.
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

0 comments on commit d02204a

Please sign in to comment.