How to trace while developing a MediaWiki extension?

74 views Asked by At

How to add tracing (for bug hunting) code to my MediaWiki extension?

When I add echo "XXX"; or var_dump(...);, I don't see it in output (despite the code line where I put this tracing works for sure, as I checked by adding exit(0); instead of this tracing and watching it crashing by exit as expected).

1

There are 1 answers

0
Tgr On BEST ANSWER

I assume you mean debug logging ("trace" is usually used for recording what method calls happen, as in XDebug function traces). The MediaWiki debugging help page has some information on it, although it's not in great shape. Basically you set $wgDebugLogGroups['mydebuglog'] to point to a logfile, and then use wfDebugLog( 'mydebuglog', 'XXX' ). (PSR-3-style structured logging is possible but requires some setting up.)

Usually var_dump works too, but there is a lot of stuff that happens outside of requests with a web response (jobs or heavy processing that's delayed until the response has been sent).

If you did mean tracing, the profiling help page has some information.