mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Appending to debug.log file
Until now debug.log files were loaded into memory, concatenated and then re-written to disk. This is an intensive operation on a large file. I've added the `FILE_APPEND` flag to append to this file instead.
This commit is contained in:
parent
9bb97140ad
commit
a8c9fffed4
@ -205,11 +205,16 @@ class Debug {
|
|||||||
* @param $message string to output
|
* @param $message string to output
|
||||||
*/
|
*/
|
||||||
public static function log($message) {
|
public static function log($message) {
|
||||||
$file = dirname(__FILE__).'/../../debug.log';
|
if (defined('BASE_PATH')) {
|
||||||
|
$path = BASE_PATH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$path = dirname(__FILE__) . '/../..';
|
||||||
|
}
|
||||||
|
$file = $path . '/debug.log';
|
||||||
$now = date('r');
|
$now = date('r');
|
||||||
$oldcontent = (file_exists($file)) ? file_get_contents($file) : '';
|
$content = "\n\n== $now ==\n$message\n";
|
||||||
$content = $oldcontent . "\n\n== $now ==\n$message\n";
|
file_put_contents($file, $content, FILE_APPEND);
|
||||||
file_put_contents($file, $content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user