* array( * 'level' => 'info', * 'appenders' => array('default') * ), * 'appenders' => array( * 'default' => array( * 'class' => 'LoggerAppenderEcho', * 'layout' => array( * 'class' => 'LoggerLayoutSimple' * ) * ) * ) * ) * ?> * * * @package log4php * @subpackage configurators * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @version $Revision$ * @since 2.2 */ class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter { public function convert($url) { if (!file_exists($url)) { throw new LoggerException("File [$url] does not exist."); } // Load the config file $data = @file_get_contents($url); if ($data === false) { $error = error_get_last(); throw new LoggerException("Error loading config file: {$error['message']}"); } $config = @eval('?>' . $data); if ($config === false) { $error = error_get_last(); throw new LoggerException("Error parsing configuration: " . $error['message']); } if (empty($config)) { throw new LoggerException("Invalid configuration: empty configuration array."); } if (!is_array($config)) { throw new LoggerException("Invalid configuration: not an array."); } return $config; } }