Pluf_Log class.
*
* The only required static method of a log writer is
* write
, which takes the stack to write as parameter.
*
* The only configuration variable of the file writer is the path to
* the log file 'pluf_log_file'. By default it creates a
* pluf.log
in the configured tmp folder.
*
*/
class Pluf_Log_File
{
/**
* Flush the stack to the disk.
*
* @param $stack Array
*/
public static function write($stack)
{
$file = Pluf::f('pluf_log_file',
Pluf::f('tmp_folder', '/tmp').'/pluf.log');
$out = array();
foreach ($stack as $elt) {
$out[] = date(DATE_ISO8601, (int) $elt[0]).' '.
Pluf_Log::$reverse[$elt[1]].': '.
json_encode($elt[2]);
}
file_put_contents($file, implode(PHP_EOL, $out).PHP_EOL, FILE_APPEND);
}
}