We all do debugging. I frequently use a file based logging function that I wrote, it was very basic. Thought it could be more improved, so here’s the improved version.
It has a small dependency, WordPress’s
WP_CONTENT_DIR constant, because I do WordPress a lot. But you can change the logging file path as you want.
Drop the function anywhere your theme/plugin. The preferred way would be using it in your MU plugin.
$simple_var = 'dynamic variable';
$test_array = array('one' => 'One', 2, '3');
wp_log( 'test', 'a simple string for testing');
wp_log( 'test', 'A simple variable: ', $simple_var );
wp_log( 'sms', 'It\'s an array: ', $test_array );
wp_log( 'truth', 'A boolean True value: ', true );
wp_log( 'test', 'It should be false: ', false );
wp_log( 'group', 'PHP object: ', $post );