Skip to content

Commit

Permalink
updated renaming for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
nnshah1 committed May 17, 2024
1 parent 5fd696c commit 22fdcd2
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions qa/L0_logging/log_format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@
import json
import google.protobuf.text_format

def parse_timestamp(timestamp):
hours, minutes, seconds = timestamp.split(':')
hours = int(hours)
minutes = int(minutes)
seconds = float(seconds)
return datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds)


module_directory = os.path.split(os.path.abspath(__file__))[0]

test_model_directory = os.path.abspath(os.path.join(module_directory, "log_models"))
Expand All @@ -58,40 +50,47 @@ def parse_timestamp(timestamp):
os.path.join(module_directory, "log_format_test_logs")
)


shutil.rmtree(test_logs_directory, ignore_errors=True)

os.makedirs(test_logs_directory)

# Regular expression pattern to capture the headers and rows
# table is
# Regular expressions for Table
# Table format is:
#
# border
# header
# header_row
# border
# row *
# data_rows
# border

table_border_regex = re.compile(r'^\+[-+]+\+$')
table_row_regex = re.compile(r'^\| (?P<row>.*?) \|$')


# Regular expression pattern for default log record
default_pattern = r'(?P<level>\w)(?P<month>\d{2})(?P<day>\d{2}) (?P<timestamp>\d{2}:\d{2}:\d{2}\.\d{6}) (?P<pid>\d+) (?P<file>[\w\.]+):(?P<line>\d+)] (?P<message>.*)'
default_log_record = r'(?P<level>\w)(?P<month>\d{2})(?P<day>\d{2}) (?P<timestamp>\d{2}:\d{2}:\d{2}\.\d{6}) (?P<pid>\d+) (?P<file>[\w\.]+):(?P<line>\d+)] (?P<message>.*)'

# Compile the regex pattern
default_regex = re.compile(default_pattern, re.DOTALL)
default_log_record_regex = re.compile(default_log_record, re.DOTALL)

LEVELS = set({"E", "W", "I"})

FORMATS = [
("default", default_regex),
("default", default_log_record_regex),
("ISO8601", ""),
("default_unescaped", default_regex),
("default_unescaped", default_log_record_regex),
("ISO8601_unescaped", ""),
]

IDS = ["default", "ISO8601", "default_unescaped", "ISO8601_unescaped"]

def parse_timestamp(timestamp):
hours, minutes, seconds = timestamp.split(':')
hours = int(hours)
minutes = int(minutes)
seconds = float(seconds)
return datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds)

validators = {}

def validator(func):
Expand Down

0 comments on commit 22fdcd2

Please sign in to comment.