Source for file File.php
Documentation is available at File.php
* "THE BEER-WARE LICENSE" (Revision 42):
* "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a beer in return.
* @package MediaSearch_Log
* @copyright Copyright (c) 2009 Sven Strittmatter
* @see MediaSearch_Log_Abstract
require_once('MediaSearch/Log/Abstract.php');
* @package MediaSearch_Log
* @copyright Copyright (c) 2009 Sven Strittmatter
public function __construct($fileName, $logLevel = Log::DISABLED) {
$message = "The log file $string does not exist ";
$message .= 'and the parent directory is not writable!';
throw new InvalidArgumentException($message);
$message = "The log file $string is not writeable!";
throw new InvalidArgumentException($message);
$this->logFile = $string;
protected function getPreamble($level, $traceLevel = null) {
$string .= 'TRACE-' . $traceLevel;
protected function log($message, array $variables = null) {
if (null !== $variables) {
$message .= ' Variables: ';
foreach ($variables as $variable) {
$message .= print_r($variable, true);
$succeded = file_put_contents($this->logFile, $message, FILE_APPEND);
if (false === $succeded) {
$message = 'Cant put content to file: ' . $this->$logFile;
throw new RuntimeException($message);
|