-
Notifications
You must be signed in to change notification settings - Fork 140
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
feat: add support for json output #618
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON is the missing one from our logging formats.
A comprehensive test would be great. But we don't really have those for loggers. There is a limited one for csv:logger/test_csvlog.py
.
configuration/test_config.py
should be extended for json.
Needs documenting in both man pages.
Checks are failing.
|
||
def comment(self, s, **args): | ||
"""JSON does not support comments""" | ||
print(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop print()
because it can't be controlled by the user.
json_dict.update({ "error": { True:"true", False:"false" } [not url_data.valid] }) | ||
|
||
self.write(json.dumps(json_dict, indent=self.indent)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other loggers call self.flush()
at the end of log_url().
|
||
def end_output(self, **kwargs): | ||
"""Nothing to do""" | ||
self.write("]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess self.close_fileoutput()
should be called as self.init_fileoutput()
had been used.
if self.has_part('result'): | ||
json_dict.update({ "result": url_data.result }) | ||
json_dict.update({ "valid": { True:"true", False:"false" } [url_data.valid] }) | ||
json_dict.update({ "error": { True:"true", False:"false" } [not url_data.valid] }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both valid and error get written based on url_data.valid? Why have both?
LoggerName = 'json' | ||
LoggerArgs = { | ||
"filename": "linkchecker-out.json", | ||
"indent": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the intent is 4 is the default in linkcheckerrc.
fixes #616