support lower verbosity #236

Closed
opened 2019-11-02 19:53:41 +00:00 by palto42 · 4 comments
Contributor

What I'm trying to do and why

I would like to restrict the console output to ERROR level if borgmatic is used in cron.

Currently the lowest verbosity 0 translates to the logging level WARNING which causes the --stats option to be displayed on all log outputs (console and syslog/logfile).

If the console level could be set to ERROR and syslog uses default 0=WARNING, then the --stats option would only add the statistics to syslog. Errors and critical messages would still show on the console as well (and trigger an email in cron).

Implementation idea

Add support for the verbosity -1 and map it to logging level ERROR.

Although negative verbosity might look strange, it would be consistent with current behavior and is backwards compatible.

#### What I'm trying to do and why I would like to restrict the console output to ERROR level if borgmatic is used in cron. Currently the lowest verbosity 0 translates to the logging level WARNING which causes the `--stats` option to be displayed on all log outputs (console and syslog/logfile). If the console level could be set to ERROR and syslog uses default 0=WARNING, then the `--stats` option would only add the statistics to syslog. Errors and critical messages would still show on the console as well (and trigger an email in cron). #### Implementation idea Add support for the verbosity **-1** and map it to logging level ERROR. Although negative verbosity might look strange, it would be consistent with current behavior and is backwards compatible.
Owner

That makes sense to me. It's similar in spirit to curl --silent or the --quiet flag of various programs. Sounds like it'd be pretty straight-forward to implement too. Are you interested in taking a crack at it?

That makes sense to me. It's similar in spirit to `curl --silent` or the `--quiet` flag of various programs. Sounds like it'd be pretty straight-forward to implement too. Are you interested in taking a crack at it?
Author
Contributor

New PR #237 for this feature.

Was not sure how should the help text describe the level -1, used option 1 in PR.

  1. Display verbose progress to the console (from none to lots: 0, 1, or 2) or only errors (-1)
  2. Display verbose progress to the console (from error-only to lots: -1, 0, 1, or 2)

Looking at the latest code I found that you defined the default log-file-verbosity as 1 instead of 0 like for the others. To me this looks inconsistent and I would prefer to align it with the other 2 cases as default 0.

New PR #237 for this feature. Was not sure how should the help text describe the level -1, used option 1 in PR. 1. `Display verbose progress to the console (from none to lots: 0, 1, or 2) or only errors (-1)` 2. `Display verbose progress to the console (from error-only to lots: -1, 0, 1, or 2)` Looking at the latest code I found that you defined the default `log-file-verbosity` as 1 instead of 0 like for the others. To me this looks inconsistent and I would prefer to align it with the other 2 cases as default 0.
Owner

Thanks, I will check out the PR when I get a chance!

Was not sure how should the help text describe the level -1, used option 1 in PR.

Seems reasonable.

Looking at the latest code I found that you defined the default log-file-verbosity as 1 instead of 0 like for the others. To me this looks inconsistent and I would prefer to align it with the other 2 cases as default 0.

My rationale for making it inconsistent at 1 was as follows: When logging to syslog, which is implicit, you might not want it to always spew info logs there. So the default is 0. But when logging to a file with --log-file, you're explicitly requesting that logs go to the file. And so it might be unexpected to a user to specify an explicit --log-file and then see no logs show up there (except warnings/errors)! In fact, the first few times I used --log-file, I said to myself: Is this even working? The file is zero bytes.

Having said all that, I don't feel strongly about it, so feel free to make it consistent if you like! After all, you are the primary user of the --log-file flag at this moment in time.

Thanks, I will check out the PR when I get a chance! > Was not sure how should the help text describe the level -1, used option 1 in PR. Seems reasonable. > Looking at the latest code I found that you defined the default log-file-verbosity as 1 instead of 0 like for the others. To me this looks inconsistent and I would prefer to align it with the other 2 cases as default 0. My rationale for making it inconsistent at 1 was as follows: When logging to syslog, which is implicit, you might not want it to always spew info logs there. So the default is 0. But when logging to a file with `--log-file`, you're explicitly requesting that logs go to the file. And so it might be unexpected to a user to specify an explicit `--log-file` and then see no logs show up there (except warnings/errors)! In fact, the first few times I used `--log-file`, I said to myself: Is this even working? The file is zero bytes. Having said all that, I don't feel strongly about it, so feel free to make it consistent if you like! After all, you are the primary user of the `--log-file` flag at this moment in time.
Owner

Just released in borgmatic 1.4.6. Nice work!

Just released in borgmatic 1.4.6. Nice work!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#236
No description provided.