Skip to content

Added json logging for check.#4581

Closed
perjahn wants to merge 2 commits intorestic:masterfrom
perjahn:master
Closed

Added json logging for check.#4581
perjahn wants to merge 2 commits intorestic:masterfrom
perjahn:master

Conversation

@perjahn
Copy link
Copy Markdown

@perjahn perjahn commented Dec 5, 2023

What does this PR change? What problem does it solve?

Adding json logging to the check command, in a similar fashion how the init command outputs json.

Was the change previously discussed in an issue or on the forum?

No

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

@perjahn
Copy link
Copy Markdown
Author

perjahn commented Dec 5, 2023

How do I update the manual at readthedocs.io?

@rawtaz
Copy link
Copy Markdown
Contributor

rawtaz commented Dec 5, 2023

The source for the documentation is in https://github.com/restic/restic/tree/master/doc . ReadTheDocs is automatically updated with the latest version which is what's on the master branch, but that only happens once the code lands on master.

Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

Sorry to be blunt. The PR completely ignores all error messages (see all Printf statements). As a consequence the JSON output would break once the check command actually detects an error, thus making the current changes pointless. This is worse than the current state of no JSON output at all.

Thus either convert everything (we can discuss how to handle stderr) or drop the PR.

bar := newProgressMax(!gopts.Quiet, 0, "snapshots")
defer bar.Done()
if !gopts.JSON {
bar := newProgressMax(!gopts.Quiet, 0, "snapshots")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With this change, chkr.Structure uses the wrong instance of the bar variable.

status := checkSuccess{
MessageType: "checked",
Message: "no errors were found",
ID: repo.Config().ID,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The ID and Repository URL aren't really relevant here and thus should be removed.

@darkdragon-001
Copy link
Copy Markdown
Contributor

Thanks for working on this! I think a single summary output in the end might be enough for many use cases (including mine of running restic from a script). Although one should reliably receive (at least) one json message (in both success and failure cases).

@MichaelEischer
Copy link
Copy Markdown
Member

MichaelEischer commented Dec 29, 2023

I think a single summary output in the end might be enough for many use cases (including mine of running restic from a script).

It's far simpler to just inspect the exit code of the check command. If it is 0 then everything is fine, otherwise there's some problem. That's exactly the same information currently provided by the JSON output.

@MichaelEischer
Copy link
Copy Markdown
Member

Closing as this PR needs a full rework anyways, feel free to open a new one if you're interested in addressing the review feedback.

@darkdragon-001 darkdragon-001 mentioned this pull request Dec 30, 2024
4 tasks
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.

4 participants