Skip to content

Conversation

@yifeih
Copy link

@yifeih yifeih commented Sep 5, 2018

This is how it works:

files-to-inspect.json contains the list of current files to check in master. If you make a PR that changes one of those files, you can just add it to unmerged in that file. A PR merge will trigger the script to squash the unmerged and master lists into a single master list and empty out the unmerged list. A release will trigger adding that release's listed files to files-to-inspect-archive.json so we can have an archive of all the files for every release.

Happy to iterate on structure and functionality

Copy link

@mccheah mccheah left a comment

Choose a reason for hiding this comment

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

Might be able to filter on lines containing logDebug, logWarning, logInfo, logError in the diff?

path: /tmp/publish_artifacts.log
destination: publish_artifacts.log


Copy link

Choose a reason for hiding this comment

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

Nit: extra whitespace


success = True
for log_file in files_to_check:
output = subprocess.check_output(['git', 'diff', 'master', log_file])
Copy link

Choose a reason for hiding this comment

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

Is part of the workflow to run this locally? If so, for those of us (myself included) who track multiple remotes, master is ambiguous here. Might want to pass the master branch to diff against as a command line argument and then default to master, then in CI we just put master or origin/master.

@yifeih
Copy link
Author

yifeih commented Sep 6, 2018

Yea I was thinking about that, but there could be multiline logs, so it's not a simple grep... let me see if I can write up some simple parser

@yifeih
Copy link
Author

yifeih commented Sep 7, 2018

@mccheah ok i attempted to parse out only the log lines. i also made it so it only checks for modified or added log lines and not deleted ones

@mccheah
Copy link

mccheah commented Sep 7, 2018

We should write a test around this with some sample diffs, see if the changes in logging are caught.


def _extract_log_line(file_lines, log_type, start_index):
log_line_string = " " + file_lines[start_index].strip()
if not log_line_string.endswith("+"):
Copy link

Choose a reason for hiding this comment

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

Tricky - this won't catch triple-quoted multi line logs.

@palantir palantir deleted a comment from vandervecken Sep 20, 2018
@lwwmanning
Copy link

@vandervecken please don't post internal links on the public internet; I deleted your comment

def _extract_variables(file_parser, log_type):
# Find the start of the log line
active_stack = []
while True:
Copy link

Choose a reason for hiding this comment

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

Instead write as while (char != "{") - avoid while true unless intending to make an infinite loop.

elif char == "\"":
return variables

def _parse_variable_outside_quotes(file_parser, close_chars):
Copy link

Choose a reason for hiding this comment

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

We can present the whole log line that changed instead of just the variable. Would remove the need for these functions.

Basically just diff the argument of logging calls - but diff it from the in-code representation.

Copy link

Choose a reason for hiding this comment

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

Talked offline, pairwise comparison line by line results in confusing output when new logging statements are added. We'll instead diff on the set of arguments of all log statements between the old version of the file and the new version of the file, irrespective of the placement of the logging statements themselves.

@yifeih
Copy link
Author

yifeih commented Sep 27, 2018

ping @mccheah

@robert3005
Copy link

Wanna close this in favour of #425 ?

@yifeih yifeih closed this Oct 29, 2018
@robert3005 robert3005 deleted the yh/check-logging branch January 28, 2019 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants