<?php if ($_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']) { $level = \PWE\Core\PWELogger::DEBUG; } else { $level = \PWE\Core\PWELogger::WARNING; } $logfile = sys_get_temp_dir() . "/pwe.log"; $tempdir = sys_get_temp_dir(); \PWE\Core\PWELogger::setStdErr($logfile); \PWE\Core\PWELogger::setStdOut($logfile); \PWE\Core\PWELogger::setLevel($level); /** @var $PWECore PWE\Core\PWECore */ $PWECore->setRootDirectory(__DIR__); $PWECore->setXMLDirectory($PWECore->getDataDirectory()); $PWECore->setTempDirectory($tempdir);
protected function loadRegistry($force = false) { if (!$force && $this->registryArray) { return; } PWELogger::debug("Loading registry file: %s", $this->registryFile); // read site structure $XML = new PWEXML($this->PWE->getTempDirectory()); $this->registryArray = array(); $XML->FileToArray($this->registryFile, $this->registryArray); $logger = $this->getModuleSettings('PWE\\Core\\PWELogger'); if ($logger['!a']) { PWELogger::setLevel(PWELogger::getLevelByName($logger['!a']['level'])); } }
public function testSetLevel() { PWELogger::setLevel(PWELogger::DEBUG); PWELogger::getLevelByName("debug"); PWELogger::getLevelByName("info"); }
<?php use PWE\Core\PWELogger; use PWE\Core\PWEAutoloader; header('Server: Apache'); header('X-Powered-By: PWE'); $root = str_replace('\\', '/', __DIR__); PWELogger::setLevel(PWELogger::WARNING); $PWECore->setStaticDirectory($root . '/img'); $PWECore->setStaticHref('/img'); $PWECore->setDataDirectory($root . '/dat'); $PWECore->setTempDirectory($root . '/dat/tmp'); PWEAutoloader::addSourceRoot($root . '/PWE');
<?php use PWE\Core\PWEAutoloader; use PWE\Core\PWECore; use PWE\Core\PWELogger; use PWE\Exceptions\PHPFatalException; use PWE\Utils\FilesystemHelper; error_reporting(E_ALL ^ E_NOTICE); $src = __DIR__ . '/..'; require_once $src . '/PWE/Core/PWELogger.php'; require_once $src . '/PWE/Core/PWEAutoloader.php'; PWELogger::setStdOut('php://stdout'); PWELogger::setStdErr('php://stdout'); PWELogger::setLevel(PWELogger::DEBUG); PWEAutoloader::addSourceRoot(__DIR__); PWEAutoloader::addSourceRoot(__DIR__ . '/..'); PWEAutoloader::addSourceRoot(__DIR__ . '/../../vendor/'); PWEAutoloader::addSourceRoot('/usr/share/php'); PWEAutoloader::activate(); require_once __DIR__ . '/../PWE/Utils/FilesystemHelper.php'; PHPFatalException::activate(); set_time_limit(180); $_SERVER["DOCUMENT_ROOT"] = dirname($_SERVER["SCRIPT_FILENAME"]); //require_once __DIR__ . '/PWE/Core/UnitTestPWECore.php'; class PWEUnitTests { public static function dumpArrayToFile($arr2, $toFile) { ob_start(); print_r($arr2); file_put_contents($toFile, ob_get_contents());