Finer grained verbosity level #64
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#64
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?
Hello,
currently, borgmatic supports three levels of verbosity, which correspond to
logging.WARNING
,logging.INFO
andlogging.DEBUG
.If I read
commands/borgmatic.py
andverbosity_to_log_level(verbosity)
correctlyno -v
corresponds toargs.verbosity = 0
=>WARNING
-v 1
corresponds toargs.verbosity = 1
=>INFO
-v 2
corresponds toargs.verbosity = 2
=>DEBUG
In practice that means:
logging.WARNING
(no command line -v given)logging.INFO
(-v 1)logging.DEBUG
(-v 2)I think there is a gap between -v 1 and -v 2 and that the output of borgmatic and borg is inconsistent (at -v 1, borgmatic already writing debug like information, borg not even progress information).
In my own borg backup script I had
--verbose --filter AME --list --stats
which imho is what most people want for logging. List just the changed files and print a final report.Can something like that be achieved with borgmatic? (set the --filter AME on the output).
So far... I will try to write up a proposal on how I would organise the log levels, probably next week.
Here's an idea: What about changing borgmatic to unconditionally use
--filter AMI
when borgmatic is at verbosity level 2? I can't think of a situation in which you'd want to see unchanged files anyway. And on the first backup of a particular system, all files should show up as additions.Thoughts?
I assume, you meant
--filter AME
?Looking at python standard loglevels, I would propose.
DEBUG
(-v 2
):--list
(no filter)INFO
(-v 1
):--list --filter AME
WARNING and above
(-v 0
):--list --filter E
I would rather make INFO more verbose. DEBUG show thinks like
which is perfect for DEBUG.
--filter AME
is imho what you rathe want to have on INFO, i.e. normal procedure with somewhat elevated verboseness.Yup, I meant to type
--filter AME
. What you propose makes sense to me! Some folks might be a little surprised by the increase in logs, but the impact is likely small.Hello,
I'm currently working on some changes to the logging system. Main change is that I remove the
verbosity
variable and instead rely on the loggers setting. Example frominfo.py
I haven't comitted anything yet. My first goal is to make the change and get the tests working, without any functional (log level -> output level) changes.
What is your opinion on that?
Editing comments does not work for me with Firefox.
The code of course, should be
producing
--info --debug
for loglevel DEBUG, the latter option overwrites previous ones.Sounds like it could certainly work, although it may be a little magical if it's relying on implicit global state. Are you thinking that
logger
is global, or passed in explicitly?What's your thinking/motivation behind the logging changes? Just that it's annoying to pass
verbosity
in everywhere? Or is there something that you can't easily do withverbosity
that you can withlogger
?logger
is returned from the python logging framework, likein
info.py
. So it is a global state, but likewise the behaviorlogger.debug(msg)
relies on the same global state.Right now, borgmatic has two "global" states. The setup of the logging framework and the verbosity level. Since the log level is derived from the verbosity in borgmatic.py, they have essentially the same value.
They are also logically the same. The log level determines what borgmatic prints, the verbosity (which results in
--info
or--debug
parameters passed to borg) determines the log level of borg.Since they are set to the same value and mean the same, I think it's the most consistent way to derive the log level of borg directly from the log level of borgmatic.
Okay.. Thanks for explaining. Makes sense to me. One thing to watch out for is that it may be a little more difficult (but still possible) to mock out a global
logger
in automated tests in order to properly set up the desired test state. One way around that would be to explicitly pass the value oflogger.getEffectiveLevel()
into a function that needs to do level-based logic. That way, you still get the benefits of consistent log level you're talking about, but also have dependencies explicitly passed in.Note that I don't feel particularly strongly about this.. I'm sure any way you decide to do this would work.
Hey! I am a little bit stucked with adapting the tests. When I run pytest, I get failed tests, but no real error message, e.g. the real reason of the failure of https://gist.github.com/floli/66c363d84517fa1fcfccf273e0b5e15b was that I removed the keyword argument verbosity and thus got a not-expected-keyword error message. I found it out, when I used pdb to step through, but the error message from the test was not helpful.
Modeled after
insert_subprocess_mock
, I createdwhich seems to work fine. Some tests need to be adapted to expect not
--debug
but--info --debug
, as I wrote above.In terms of the failed tests without a real error message, that's one of the major limitations/annoyances I've found with flexmock. If the method signature doesn't match, then you're just kind of out of luck. Many other Python mocking frameworks don't have that same problem, but have even worse problems IMO. (Example:
unittest.mock
.)Now that your logging refactor has landed, I think this is done! If not, please let me know, or open a new ticket with any additional work. Thanks.
Finally released (borgmatic 1.2.3)!
FYI, some discussion about perhaps altering or backing out some of these changes: witten/borgmatic#272 ... Specifically the per-file detail at verbosity 1. You may want to weigh in there.
EDIT: Corrected ticket number.