Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support express.js #19

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 7 additions & 4 deletions misc/log-analytics/import_logs.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,19 @@ def check_format(self, file):
_NCSA_EXTENDED_LOG_FORMAT = (_COMMON_LOG_FORMAT +
' "(?P<referrer>.*?)" "(?P<user_agent>.*?)"'
)
_EXPRESSJS_LOG_FORMAT = (
'(?P<ip>\S+) \S+ \S+ \[(?P<date>.*) (?P<timezone>.*?)\] '
'"\S+ (?P<path>.*?) \S+" (?P<status>\S+) (?P<length>\S+)'
)


FORMATS = {
'common': RegexFormat('common', _COMMON_LOG_FORMAT),
'common_vhost': RegexFormat('common_vhost', _HOST_PREFIX + _COMMON_LOG_FORMAT),
'ncsa_extended': RegexFormat('ncsa_extended', _NCSA_EXTENDED_LOG_FORMAT),
'common_complete': RegexFormat('common_complete', _HOST_PREFIX + _NCSA_EXTENDED_LOG_FORMAT),
'iis': IisFormat(),
'expressjs': RegexFormat('expressjs', _EXPRESSJS_LOG_FORMAT, date_format='%a, %d %b %Y %H:%M:%S'),
}


Expand Down Expand Up @@ -1391,11 +1397,8 @@ def invalid_line(line, reason):
# Parse timezone and substract its value from the date
try:
timezone = float(match.group('timezone'))
except IndexError:
except (IndexError, ValueError):
timezone = 0
except ValueError:
invalid_line(line, 'invalid timezone')
continue

if timezone:
hit.date -= datetime.timedelta(hours=timezone/100)
Expand Down