Skip to content

Commit b6e0b72

Browse files
Merge pull request #14 from pitangainnovare/impl/regex_domain
Implementa regex para detectar logs em outro formato
2 parents 4ee470f + 3e6639a commit b6e0b72

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

scielo_log_validator/validator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ def _get_content_summary(path, total_lines, sample_lines):
134134
if line_counter in eval_lines:
135135
match = re.search(values.PATTERN_IP_DATETIME_OTHERS, decoded_line)
136136

137-
if match and len(match.groups()) == 3:
138-
ip_value = match.group(1)
137+
if match and len(match.groups()) == 5:
138+
ip_value = match.group(2)
139139
ip_type = _is_ip_local_or_remote(ip_value)
140140
ips[ip_type] += 1
141141

142-
matched_datetime = match.group(2)
142+
matched_datetime = match.group(3)
143143
try:
144144
year, month, day, hour = _extract_year_month_day_hour(matched_datetime)
145145

@@ -213,7 +213,7 @@ def _date_is_much_greater(date_object, file_object_date, days_delta):
213213
return True
214214

215215

216-
def _analyse_dates(results, days_delta=2):
216+
def _analyse_dates(results, days_delta=5):
217217
file_path_date = results.get('path', {}).get('date', '')
218218
file_content_dates = results.get('content', {}).get('summary', {}).get('datetimes', {})
219219
probably_date = results.get('probably_date')

scielo_log_validator/values.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333

3434
PATTERN_PAPERBOY = r'^\d{4}-\d{2}-\d{2}[\w|\.]*\.log\.gz$'
3535

36-
PATTERN_IP_DATETIME_OTHERS = r'^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(.*)\] \"(.*)\"$'
36+
PATTERN_IP_DATETIME_OTHERS = r'^([\w|\W]* |)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(.*)\] (\".*\")(.*)$'
3737

3838
PATTERN_IP_DATETIME_RESOURCE_STATUS_LENGHT_REFERRER_EQUIPMENT = r'^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(.*)\] \"GET (.*) .*\" (\d{3}) (\d*) \"(.*)\" \"(.*)\"$'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
setuptools.setup(
1818
name="scielo-log-validator",
19-
version="0.2.6",
19+
version="0.3.0",
2020
author="SciELO",
2121
author_email="scielo-dev@googlegroups.com",
2222
description="",

0 commit comments

Comments
 (0)