Or you can try setting up an XDEBUG connection, which seems like a lot of work for a couple of diagnostic messages, and if you’re running on some shared hosting plan, you can probably forget about that anyhow.
So I figured why not just route the diagnostics out through a socket and write the output on a console somewhere?
So after a little work, AP5L_Debug now offers two variations.
- AP5L_Debug_Stdout just echoes the data to the output stream (well not quite: if no headers have been sent, it buffers the data and then writes everything on the first post-header output, or on an explicit flush).
- AP5L_Debug_Udp sends the data to the address and port of your choice. There’s also AP5L_Debug_Listener, which is a crude command line tool that reads data from the port and dumps the information to the console.
It worked like a charm. The diagnostics identified what was a pretty simple mistake, I fixed the code, and the problem was solved in no time.
Also, since the diagnostics don’t mess up the generated page, I can see using this technique even when there’s no AJAX involved. That’s more than welcome.