metabrainz / picard-plugins

Picard plugins: use 1.0 branch for Picard < 2.0 (python 2/Qt4) and 2.0 branch for Picard >= 2.0 (python 3/Qt5)
https://picard.musicbrainz.org/plugins/
145 stars 95 forks source link

Add new "Script Logger" plugin #363

Closed rdswift closed 1 year ago

rdswift commented 1 year ago

This plugin provides a new script function $logline() to write entries to Picard's system log. By default, the log level is set at Info, but any level can be used by providing the level as an optional second parameter to the function.

The function is used as:

$logline(text[,level])

where text is the text to write to the log. The entry will be written at log level Info by default, but this can be changed by specifying a different level as an optional second parameter. Allowable log levels are:

If an unknown level is entered, the function will use the default Info level.

Sophist-UK commented 1 year ago

Nice!!!!

rdswift commented 1 year ago

I wonder if it would make sense to write all the output lines with a fixed, common prefix to easily identify the log lines created by this plugin?

I actually had this originally set up to preface each line with "Script Logger:", but when added to the plugin path that Picard includes automatically, it became a bit lengthy (and I couldn't come up with a way to prevent Picard from including the full path to the plugin). It would actually be nice to preface the text with the script name and line number (perhaps as options), but I couldn't find a way to retrieve the name of the currently running script.

Any suggestions on how to overcome these?