Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6ef59e6
add structured logging style script and github workflow
asl3 Jul 5, 2024
d640b94
improve error message
asl3 Jul 5, 2024
b862228
match scala build error message
asl3 Jul 5, 2024
42de4c5
account for line breaks in regex match
asl3 Jul 6, 2024
95e86cc
fix script name
asl3 Jul 6, 2024
667bc58
update regex
asl3 Jul 6, 2024
58e763d
separate mono regex
asl3 Jul 8, 2024
0f26de8
add java files check
asl3 Jul 8, 2024
8959688
reformat python
asl3 Jul 8, 2024
0bd4e8a
check only scala files
asl3 Jul 8, 2024
c8b1b27
add CodeGenerator to exclude list due to large code formatter variable
asl3 Jul 8, 2024
22940d7
Merge branch 'master' into structuredlogstylescript
asl3 Jul 9, 2024
ae67d94
check if script exists
asl3 Jul 9, 2024
9f17a40
fix inner regex
asl3 Jul 9, 2024
4bb0ccf
add exclude file
asl3 Jul 9, 2024
97c3a74
revise error message
asl3 Jul 10, 2024
1b3950d
update error message
asl3 Jul 10, 2024
6f47405
check if file is a directory
asl3 Jul 10, 2024
dd0fb47
update regex
asl3 Jul 10, 2024
d6206a9
rename script
asl3 Jul 11, 2024
62e3c0d
style
asl3 Jul 11, 2024
e6d88b2
update gha yml
asl3 Jul 11, 2024
72f0c1b
line char max
asl3 Jul 11, 2024
7bdf67c
stylize the error message
asl3 Jul 15, 2024
bc400cc
Merge branch 'master' into structuredlogstylescript
asl3 Jul 17, 2024
bed4256
modify + regex
asl3 Jul 17, 2024
44ef1a5
Merge branch 'master' into structuredlogstylescript
asl3 Jul 18, 2024
20dd905
Merge branch 'master' into structuredlogstylescript
asl3 Jul 18, 2024
a253657
run script with python3.9
asl3 Jul 19, 2024
0c22383
update success condition check
asl3 Jul 19, 2024
2333388
lint fix
asl3 Jul 20, 2024
5f78989
reformat
asl3 Jul 20, 2024
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
Prev Previous commit
Next Next commit
add java files check
  • Loading branch information
asl3 committed Jul 8, 2024
commit 0f26de8d7d589c65ed2c3f0fa9c50fa153414a7d
41 changes: 9 additions & 32 deletions dev/structured-logging-style.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def main():

nonmigrated_files = {}

scala_files = glob.glob(os.path.join(SPARK_HOME, '**', '*.scala'), recursive=True)
files = [file for ext in ('*.scala', '*.java')
for file in glob.glob(os.path.join(SPARK_HOME, '**', ext), recursive=True)]

for file in scala_files:
for file in files:
skip_file = False
for exclude_pattern in excluded_file_patterns:
if re.search(exclude_pattern, file):
Expand All @@ -52,7 +53,6 @@ def main():
content = f.read()

log_statements = re.finditer(log_pattern, content, re.DOTALL)
# log_statements = [statement.group(1).strip() for statement in log_statements]

if log_statements:
nonmigrated_files[file] = []
Expand All @@ -62,41 +62,18 @@ def main():
preceding_content = content[:start_pos]
line_number = preceding_content.count('\n') + 1
start_char = start_pos - preceding_content.rfind('\n') - 1
nonmigrated_files[file].append((line_number, start_char, log_statement.group(1)))

# for log_statement in log_statements:
# if compiled_inner_log_pattern.search(log_statement):
# nonmigrated_files[file].append()


# matches = list(pattern.finditer(content))
# matches2 = pattern.findall(content)
#
# for m in matches2:
# print(f"****** ${m}")
#
# if matches:
# nonmigrated_files[file] = []
# for match in matches:
# start_pos = match.start()
# preceding_content = content[:start_pos]
# line_number = preceding_content.count('\n') + 1
# start_char = start_pos - preceding_content.rfind('\n') - 1
# nonmigrated_files[file].append((line_number, start_char))
nonmigrated_files[file].append((line_number, start_char))

if not nonmigrated_files:
print("Structured logging style check passed.")
sys.exit(0)
else:
for file_path, issues in nonmigrated_files.items():
if issues:
print(file_path)
# for file_path, issues in nonmigrated_files.items():
# for line_number, start_char in issues:
# pass
# print(f"[error] {file_path}:{line_number}:{start_char}")
# print("""[error]\t\tLogging message should use log"..." instead of s"..." and variables should be wrapped in `MDC`s.
# Refer to Structured Logging Framework guidelines in the file `internal/Logging.scala`.""")
for line_number, start_char in issues:
pass
print(f"[error] {file_path}:{line_number}:{start_char}")
print("""[error]\t\tLogging message should use log"..." instead of s"..." and variables should be wrapped in `MDC`s.
Refer to Structured Logging Framework guidelines in the file `internal/Logging.scala`.""")

sys.exit(-1)

Expand Down