[Reviewer: Matt] P-Served-User

Matt,

I tracked down the corruption in https://github.com/Metaswitch/sprout/issues/281 to the fact that pjsip_parse_uri expects a NULL-terminated string which we didn't provide.

My first commit fixes this: the second two commits add debug-level logging which I found useful in narrowing this down. I think it is useful in terms of giving insight into potential bugs and misconfigurations, but I could be persuaded that it's a bit too verbose.