initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

View File

@ -0,0 +1,76 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package symfony
* @subpackage log
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id: sfFileLogger.class.php 3329 2007-01-23 08:29:34Z fabien $
*/
class sfFileLogger
{
protected
$fp = null;
/**
* Initializes the file logger.
*
* @param array Options for the logger
*/
public function initialize($options = array())
{
if (!isset($options['file']))
{
throw new sfConfigurationException('File option is mandatory for a file logger');
}
$dir = dirname($options['file']);
if (!is_dir($dir))
{
mkdir($dir, 0777, 1);
}
if (!is_writable($dir) || (file_exists($options['file']) && !is_writable($options['file'])))
{
throw new sfFileException(sprintf('Unable to open the log file "%s" for writing', $options['file']));
}
$this->fp = fopen($options['file'], 'a');
}
/**
* Logs a message.
*
* @param string Message
* @param string Message priority
* @param string Message priority name
*/
public function log($message, $priority, $priorityName)
{
$line = sprintf("%s %s [%s] %s%s", strftime('%b %d %H:%M:%S'), 'symfony', $priorityName, $message, DIRECTORY_SEPARATOR == '\\' ? "\r\n" : "\n");
flock($this->fp, LOCK_EX);
fwrite($this->fp, $line);
flock($this->fp, LOCK_UN);
}
/**
* Executes the shutdown method.
*/
public function shutdown()
{
if ($this->fp)
{
fclose($this->fp);
}
}
}

View File

@ -0,0 +1,95 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package symfony
* @subpackage log
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id: sfWebDebugLogger.class.php 3329 2007-01-23 08:29:34Z fabien $
*/
class sfWebDebugLogger
{
protected
$webDebug = null;
/**
* Initializes the web debug logger.
*
* @param array Logger options
*/
public function initialize($options = array())
{
if (!sfConfig::get('sf_web_debug'))
{
return;
}
$this->webDebug = sfWebDebug::getInstance();
}
/**
* Logs a message.
*
* @param string Message
* @param string Message priority
* @param string Message priority name
*/
public function log($message, $priority, $priorityName)
{
if (!sfConfig::get('sf_web_debug'))
{
return;
}
// if we have xdebug, add some stack information
$debug_stack = array();
if (function_exists('xdebug_get_function_stack'))
{
foreach (xdebug_get_function_stack() as $i => $stack)
{
if (
(isset($stack['function']) && !in_array($stack['function'], array('emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug', 'log')))
|| !isset($stack['function'])
)
{
$tmp = '';
if (isset($stack['function']))
{
$tmp .= 'in "'.$stack['function'].'" ';
}
$tmp .= 'from "'.$stack['file'].'" line '.$stack['line'];
$debug_stack[] = $tmp;
}
}
}
// get log type in {}
$type = 'sfOther';
if (preg_match('/^\s*{([^}]+)}\s*(.+?)$/', $message, $matches))
{
$type = $matches[1];
$message = $matches[2];
}
// build the object containing the complete log information.
$logEntry = array(
'priority' => $priority,
'priorityString' => $priorityName,
'time' => time(),
'message' => $message,
'type' => $type,
'debugStack' => $debug_stack,
);
// send the log object.
$this->webDebug->log($logEntry);
}
}