How to print with style to watchdog without devel

Jun
2015
10

So sometimes i want to make some development on live sites that i do not want to enable and disable the Devel module due to perfomance issues.
I found from dropbucket (http://dropbucket.org/node/72) this awesome snippet that helps me a lot with "background backoffice" development. You can print arrays or objects to watchdog that looks pretty and structured too (in a more human-readable way actually)!

<?php
    watchdog
("my_module", '<pre>' . print_r( $my_array_or_object, true) . '</pre>');
?>

Have fun!
p.s: Do not forget to enable the System Log module (database logging / dblog module) for that. The admin page of the module is this: admin/reports/dblog

this is an arrow pointing back to the top of the page