Debug plugins with a log file
We cant use console.log anymore, so i needed a tool to display log messages.
For that i created a component named DebugTools.
Usage :
1)add the component in the plugin directory (documents/musescore4/plugins/mplugin)
2)Add the reference part in your main plugin.
3)Use the methods
This was written for MS4 but could be easily adapted to other versions.
I use that tools also to dump different objects (segment, element ,..) but this is another story !
Attachment | Size |
---|---|
DebugTools1.PNG | 58.26 KB |
DebugTools2.PNG | 50.19 KB |
Modele.PNG | 26.24 KB |
Comments
Please share the qml file
In reply to Please share the qml file by elsewhere
That's done
https://musescore.org/en/project/debugtools-using-log-file-debug-plugins
In reply to That's done https:/… by dominiqueverriere
Many Thanks
Nice one. Thanks for sharing it. Helpful for porting MS3 plugin's to MS4.
In reply to Nice one. Thanks for sharing… by parkingb
Little suggestion. The
console
object has other interesting log methods such astrace
,warn
anderror
.This could be nice to have similar functions in you Item.
That way the info written to the file could be prefixed with the level of the debug (similar to the PatternLayout of Log4j):
In reply to Little suggestion. The… by parkingb
Yes very good idea, i m still writing these tools, i could share the appends i did (exceptions management, stack trace, dump segments and elements)
It will take some time as i m really in the begin of investigations of these tools.
In reply to Yes very good idea, i m… by dominiqueverriere
The only part I'm doubtful it will work is using this approach for logging in separated ".js" files.
I put most of my plugin code in external javascript files that I can reuse across all my plugin(*)
I wonder if I could manage to access that
debugTools
item from those javascript libraries...I'll have a try.
(*): That I call with qml statements such as
import "selectionhelper.js" as SelHelper
and then calls such as
var chords = SelHelper.getChordsFromCursor(curScore)