Don't color syslog output #197
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#197
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
View syslog output.
Steps to reproduce
Log to syslog from borgmatic, presumably with a non-systemd syslog daemon?
Actual behavior
Color codes in syslog end up looking like:
Expected behavior
No color codes in syslog.
Fixed in master. This will be part of the next release!
Just released as part of borgmatic 1.3.7.
The syslog unicode color characters seem to be back since 1.3.8 (or 1.3.9).
Setting
output.color=false
disables the colors for the console, but still puts them in syslog. 😿Also,
--syslog-verbosity 0
has no effect. Warnings get sent to syslog anyways. Example command isborgmatic list -v 2 --syslog-verbosity 0
. It even includes the debugging messages (from-v 2
) as "WARNING".Oh no! Do you know what syslog daemon you're using? systemd? rsyslog? And you're seeing color escape codes in the log output? The color formatting is only applied to the console logging handler now, so I'm a bit unsure what might be going on. Any more info you can provide would be helpful.
Well, this is actually by design! What's going on is that verbosity level zero does surface both warnings and errors, but suppresses any logs below that log level. The idea is that this is a useful default log level for, say, a cron job, where you don't want to get the play-by-play if everything was successful but you definitely want to see logs if something went wrong.
Then, as perhaps an abuse of this property, borgmatic logs Borg's
list
output at theWARNING
level, with the idea that if you runborgmatic list
, you actually want to see list output regardless of verbosity level. It would be pretty weird if, at verbosity level zero, you ranborgmatic list
and didn't get any list output at all!I'm certainly open to revisiting any of this, but that's the current thinking anyway. Let me know your thoughts!
I'm using rsyslog-8.24.0 (the default on CentOS 7.6).
UPDATE: Oops, my bad U+FEFF is actually the 'ZERO WIDTH NO-BREAK SPACE', not a color code. I'm bad at unicode. There are no color escape codes in the syslog at all anymore. 😥
One of this night's backup runs writes this to /var/log/messages:
Ah, then I misunderstood the recent commit (
de94001508
) that made "error" the default logging level (even if it was temporary).Can I disable syslog logging completely when running interactively (e.g. with a setting in the config file = less typing in the console) and override it with a parameter when running in the daily cron job?
I think that would be ideal for my use case:
When I'm typing the borgmatic commands into the console, I see the output and don't want my typos (happens quite a lot, especially with borg patterns°...) to spam the syslog with ERROR and CRITICAL. 😊
° example, command was
borgmatic extract --archive netcup-centos-2019-06-20T03:00:16.946917 --restore-path "sh:**/openfire/openfire.xml"
(path doesn't exist in backup, I was missing the intermediate "conf" directory).Yeah, this is actually a unicode byte order mark. I thought I was being clever by including it in case the message contained unicode, but I didn't realize that rsyslog would render it literally. I'll remove it!
I was being perhaps needlessly succinct in that commit message.. It's errors and warnings (and "warnings") as you've discovered!
This seems like a valid use case to me.. Let me think about the best way to solve this. One related idea is that we can generally detect when the terminal is interactive or not. Maybe when interactive, we should never log to syslog (unless requested), and when non-interactive, always log to syslog?
Okay, I just released borgmatic 1.3.12. This removes the byte order mark, and disables syslog output entirely when the console is interactive. At the moment, this is not override-able. But we can always revisit in the future if there's a valid use case for logging to syslog at an interactive console.
Let me know how it works out for you, and thanks for reporting the various issues!