-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
PICARD-2757: Add a command-line option to enable audit #2316
Conversation
Looks like it could be a useful debugging tool. Just a "heads up" that once it's merged we'll need to update the documentation at https://picard-docs.musicbrainz.org/en/appendices/command_line.html |
@zas For those of us onlookers, can you give one or two use cases showing how this might be used e.g. when someone says in the forums that they are having problems saving files and / or by Picard or Picard plugin developers? |
@Sophist-UK One example zas showed me yesterday was to audit all calls to functions in the os module:
Or here is a run tracking all calls to
Why is it opening the plugin ZIPs so many times? That might be something to investigate. |
I improved (and fixed the code) a bit. The matched prefix is now added to the line. If you have
It also handles correctly |
5870cd2
to
20b279a
Compare
0541560
to
3f527e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good.
This can give use a useful tool for gathering information on otherwise hard to track down issues. If unused this has no impact and the code is small enough to be no burden.
…dithook() That's a debugging feature. Try '--audit os.mkdir,open' or '--audit all'
``` audit:os:216102:48.414292335510254 os.mkdir args=(b'/home/zas/.config/MusicBrainz', 511, -1) audit:open:216102:48.414377212524414 open args=(b'/home/zas/.config/MusicBrainz/.Picard.ini.synclock', 'a', 525377)audit:open:216130:10.849092245101929 open args=('/tmp/picardxd4csqqv.jpg', None, 655554) audit:open:216130:10.852484703063965 open args=(58, 'w', 524865) audit:open:216130:10.859289407730103 open args=(b'/home/zas/Musique/Budgie/The MCA Albums 1973-1975/3-02 Slipaway.flac', 'r', 524288) audit:open:216383:10.860839128494263 open args=(b'/home/zas/Musique/Budgie/The MCA Albums 1973-1975/3-03 Who Do You Want for Your Love_.flac', 'r', 524288) ```
Not directly linked to audit events
This method isn't strictly related to events, but rather to dot-separated keys, use more generic names
@phw I did some cleanup changes, can you review again? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just minor comments / questions, otherwise LGTM
Suggested by phw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Problem
Solution
Using Python 3.8 sys.addaudithook()
That's a debugging feature.
Try '--audit os' or '--audit all'
Typical output would be something like:
Format is audit:threadid:seconds_since_start event args
Action