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](http://drupal.stackexchange.com/questions/94501/how-to-export-recent-logs-report-in-csv-file-drupal-7/94502#94502). 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'])`](https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/t/7) and [`format_string($log['message'], $log['variables'])`](https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/format_string/7) but this won't work.