Why might my PHP log file not entirely be text?

Posted by Fletcher Moore on Stack Overflow See other posts from Stack Overflow or by Fletcher Moore
Published on 2010-05-12T21:08:57Z Indexed on 2010/05/12 21:14 UTC
Read the original article Hit count: 229

Filed under:
|
|

I'm trying to debug a plugin-bloated Wordpress installation; so I've added a very simple homebrew logger that records all the callbacks, which are basically listed in a single, ultimately 250+ row multidimensional array in Wordpress (I can't use print_r() because I need to catch them right before they are called).

My logger line is $logger->log("\t" . $callback . "\n");

The logger produces a dandy text file in normal situations, but at two points during this particular task it is adding something which causes my log file to no longer be encoded properly. Gedit (I'm on Ubuntu) won't open the file, claiming to not understand the encoding. In vim, the culprit corrupt callback (which I could not find in the debugger, looking at the array) is about in the middle and printed as ^@lambda_546 and at the end of file there's this cute guy ^M. The ^M and ^@ are blue in my vim, which has no color theme set for .txt files. I don't know what it means.

I tried adding an is_string($callback) condition, but I get the same results.

Any ideas?

© Stack Overflow or respective owner

Related posts about php

Related posts about encoding