Skip to content
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

Add new "Script Logger" plugin #363

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Conversation

rdswift
Copy link
Contributor

@rdswift rdswift commented Oct 24, 2023

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:

  • E (Error)
  • W (Warning)
  • I (Info)
  • D (Debug)

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

@Sophist-UK
Copy link
Contributor

Nice!!!!

Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. I guess the plugin also can be useful for debugging. It's clearly something advanced, so I'd be happy to keep this as a plugin only.

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?

@rdswift
Copy link
Contributor Author

rdswift commented Oct 25, 2023

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?

@rdswift rdswift force-pushed the script_logger branch 2 times, most recently from c6e72e9 to ceda8a4 Compare October 26, 2023 17:54
@rdswift rdswift merged commit d1e6352 into metabrainz:2.0 Oct 26, 2023
16 checks passed
@rdswift rdswift deleted the script_logger branch October 26, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants