I would like to export everything in the watchdog
table to a CSV file occasionally using hook_cron()
. I do not have access to PHPMyAdmin and don't want to waste time with modules like so.
Right now, I have all records for the watchdog table, but I can't figure out how to format messages properly.
$log = db_query("SELECT uid, type, message, variables, severity, location, timestamp FROM {watchdog}")->fetchAll();
dsm($log);
// Output: "message => '%type: !message in %function (line %line of %file).'"
// "variables => 'a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:27:"Undefined index:..."
How the heck am I supposed to replace symbols in $log['message']
with what's in $log['variables']
?
I have tried using t($log['message'], $log['variables'])
and format_string($log['message'], $log['variables'])
but this won't work.