40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 14/feb/2013
|
|
*/
|
|
|
|
use ASD\FileSystemManager;
|
|
|
|
class FileLogger extends LoggingFacility{
|
|
private $filePath;
|
|
|
|
public function __construct($name,$catalogManager,$filePath,$usedate=false) {
|
|
$this->filePath = $filePath;
|
|
touch($this->filePath);
|
|
chown($this->filePath, "www-data");
|
|
parent::__construct($name,$catalogManager,$usedate);
|
|
}
|
|
|
|
protected function writelog($level,$message,&$data) {
|
|
// $translate_level = LOG_DEBUG;
|
|
// if($level == LoggingFacility::$LEVEL_ERROR) $translate_level = LOG_ERROR;
|
|
// else if($level == LoggingFacility::$LEVEL_WARNING) $translate_level = LOG_WARNING;
|
|
// else if ($level == LoggingFacility::$LEVEL_INFO) $translate_level = LOG_INFO;
|
|
// syslog($translate_level,$message);
|
|
// if (!SFSManager::fileExists($this->filePath)){
|
|
// SFSManager::touchFile($this->filePath);
|
|
// }
|
|
SFSManager::appendToFile($message."\n",$this->filePath);
|
|
}
|
|
|
|
protected function getIndicationForLevel($level) {
|
|
if($level == LoggingFacility::$LEVEL_ERROR) return " [ERROR] ";
|
|
else if($level == LoggingFacility::$LEVEL_WARNING) return " [WARNING] ";
|
|
else if ($level == LoggingFacility::$LEVEL_INFO) return " [INFO] ";
|
|
else return " [DEBUG] ";
|
|
}
|
|
|
|
}
|
|
|
|
?>
|