Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

major0
Copy link

@major0 major0 commented Mar 10, 2022

fixes #616

Copy link
Contributor

@cjmayo cjmayo left a 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)
Copy link
Contributor

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))

Copy link
Contributor

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("]")
Copy link
Contributor

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] })
Copy link
Contributor

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": "",
Copy link
Contributor

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.

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.

feature: support json output
2 participants