Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "pypi"

[packages]
raven = ">=3.3.2"
tailer = ">=0.3"
tailhead = ">=1.0.2"

[dev-packages]
tox = "*"
Expand Down
19 changes: 6 additions & 13 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
raven>=3.3.2
tailer>=0.3
tailhead>=1.0.2
18 changes: 10 additions & 8 deletions sentrylogs/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Log file parsers provided by Sentry Logs
"""
import tailer # same functionality as UNIX tail in python
import tailhead # same functionality as UNIX tail in python

from ..helpers import send_message

Expand All @@ -27,22 +27,24 @@ def follow_tail(self):
Read (tail and follow) the log file, parse entries and send messages
to Sentry using Raven.
"""

try:
logfile = open(self.filepath)
follower = tailhead.follow_path(self.filepath)
except (FileNotFoundError, PermissionError) as err:
raise SystemExit("Error: Can't read logfile %s (%s)" %
(self.filepath, err))

for line in tailer.follow(logfile):
for line in follower:
self.message = None
self.params = None
self.site = None

self.parse(line)
send_message(self.message,
self.params,
self.site,
self.logger)
if line is not None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simply

if line:

... which is pythonic. Also, an empty line wouldn't need to be parsed, right?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think an empty line could be important to parse. Empty lines are often used as separators. Not used that way for nginx, but this part of the code is not nginx specific.

self.parse(line)
send_message(self.message,
self.params,
self.site,
self.logger)

def parse(self, line):
"""
Expand Down