| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Output driver for writing trace messages into a text file.
|
| 7 |
*/
|
| 8 |
|
| 9 |
//////////////////////////////////////////////////////////////////////////////
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implements hook_trace().
|
| 13 |
*/
|
| 14 |
function trace_file_trace($type, $msg, $time = NULL) {
|
| 15 |
$type = sprintf('%-7s', strtoupper($type));
|
| 16 |
$time = _trace_format_timedelta($time);
|
| 17 |
$header = sprintf(TRACE_FORMAT, TRACE_ID, $time, $type) . ' ';
|
| 18 |
|
| 19 |
if (!is_array($msg)) {
|
| 20 |
$output = $header . $msg;
|
| 21 |
}
|
| 22 |
else {
|
| 23 |
$output = array($header . array_shift($msg));
|
| 24 |
foreach ($msg as $line) {
|
| 25 |
$output[] = str_repeat(' ', strlen($header)) . $line;
|
| 26 |
}
|
| 27 |
$output = implode("\n", $output);
|
| 28 |
}
|
| 29 |
|
| 30 |
if (($file = fopen(TRACE_FILE, 'ab'))) {
|
| 31 |
fwrite($file, $output . "\n");
|
| 32 |
fclose($file);
|
| 33 |
}
|
| 34 |
}
|
| 35 |
|
| 36 |
//////////////////////////////////////////////////////////////////////////////
|