1 [[!meta author="spalax"]]
2 [[!template id=plugin name=verboserpc author="[[Louis|spalax]]"]]
4 Debugging [external plugins](//ikiwiki.info/plugins/write/external/) is a pain, as soon as RPC is involved… This kind-of plugin tries to make it a little bit less painful.
6 It acts as a proxy between Ikiwiki and the plugin (which, for the record, is an executable program communicating with Ikiwiki using [XML RPC](http://www.xmlrpc.com/) on standard input/output), and logs everithing on standard error.
12 A sample output of a wiki compilation is shown below.
14 $ ikiwiki --setup wiki.setup --refresh --verbose
15 -> <?xml version="1.0" encoding="utf-8"?><methodCall><methodName>import</methodName><params></params></methodCall>
16 <- <?xml version='1.0'?>
18 <- <methodName>hook</methodName>
21 <- <value><string>call</string></value>
24 <- <value><string>getsetup</string></value>
27 <- <value><string>type</string></value>
30 <- <value><string>getsetup</string></value>
33 <- <value><string>id</string></value>
36 <- <value><string>foo</string></value>
39 <- <value><string>last</string></value>
42 <- <value><boolean>0</boolean></value>
46 -> <?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><string>1</string></value></param></params></methodResponse>
47 <- <?xml version='1.0'?>
54 <- <value><string></string></value>
67 Let us say you want to debug a plugin `foo`, located somewhere in your [`libdir`](https://ikiwiki.info/plugins/install/).
69 1. Do not not enable plugin `foo` in the ikiwiki setup file.
70 2. Create a symbolic link named `foo.verboserpc` in one of your `libdir`, linking to the `verboserpc` plugin.
71 3. In your setup file, enable plugin `foo.verboserpc`.
73 That's it. When called, the `verboserpc` plugin will be called as `foo.verboserpc`, and will run program `foo`, while transmitting (to Ikiwiki and `foo`) and logging (to standard error) any input/output.
77 Well… External plugins are still a pain to debug, even with this tool. If your plugin is written using python, and you are using the [`proxy`](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=plugins/proxy.py;h=b61eb466c8d47ef839fc24e5d0ba54be3a9b23fa;hb=HEAD), it might be useless, since this proxy already have an option to log RPC calls (by giving `debug_fn=sys.stderr.write` as an option to the constructor of [`IkiWikiProcedureProxy`](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=plugins/proxy.py;h=b61eb466c8d47ef839fc24e5d0ba54be3a9b23fa;hb=HEAD#l217)).
79 I am not sure that this plugin is the solution to the problem of debugging external plugins. I am still publishing it here, hoping that someone might improve it into something useful…
81 # Download and install
83 Code and documentation can be found here : [[https://atelier.gresille.org/projects/gresille-ikiwiki/wiki/VerboseRPC]].