Example #1
0
 /**
  * Returns debug report
  */
 public function getReport()
 {
     $report = array();
     $report['restDebug'] = $this->debug->generateOutput();
     $reportEZDebug = $this->eZDebug->printReportInternal(false);
     $report['eZDebug'] = explode("\n", $reportEZDebug);
     return $report;
 }
/**
 * Callback function for the trigger_error function.
 */
function errorHandler($code, $msg, $file, $line)
{
    if (true && $code == E_USER_NOTICE) {
        // ezcDebug is auto_included, therefore when debug is disabled this class is not loaded at all.
        // Func: START_TIMER, STOP_TIMER, or LOG.
        // Msg: Message without the 'encoded parameters'.
        // source: Paynet, example, etc.
        // category: Template, SQL, etc.
        $dm = new ezcDebugMessage($msg);
        $dm->setDefaultSource("Paynet");
        if ($dm->isLog()) {
            ezcDebug::getInstance()->log($dm->message, $dm->verbosity, $dm->source, $dm->category, array("file" => $file, "line" => $line));
        } else {
            if ($parsedMsg->isStartTimer()) {
                $ezcDebug->getInstance()->startTimer($dm->name, $dm->source, $dm->category);
            } else {
                if ($dm->isStopTimer()) {
                    $ezcDebug->getInstance()->stopTimer($dm->name);
                }
            }
        }
    } else {
        // E_USER_WARNING, E_USER_ERROR
        $m = new ezcMessage($msg);
        $m->setDefaultSource("Paynet");
        // Severity is translated: E_USER_WARNING => WARNING, E_USER_ERROR => ERROR.
        ezcLog::getInstance()->log($m->message, $m->severity, $m->source, $m->category, array("file" => $file, "line" => $line));
    }
}
Example #3
0
 public function TestDebugHandler($errno, $errstr, $errfile, $errline)
 {
     switch ($errno) {
         case E_USER_ERROR:
         case E_USER_WARNING:
         case E_USER_NOTICE:
             ezcDebug::debugHandler($errno, $errstr, $errfile, $errline);
             break;
         default:
             print "{$errstr} in {$errfile} on line {$errline}\n";
             break;
     }
 }
Example #4
0
        ?>
        		
            </div>
            </div>
        	<?php 
    }
    ?>
    </div>
    <?php 
}
?>

</div>

<?php 
include_once erLhcoreClassDesign::designtpl('pagelayouts/parts/page_footer.tpl.php');
?>

</div>
</div>


<?php 
if (erConfigClassLhConfig::getInstance()->getSetting('site', 'debug_output') == true) {
    $debug = ezcDebug::getInstance();
    echo $debug->generateOutput();
}
?>

</body>
</html>
Example #5
0
 protected function setUp()
 {
     $this->dbg = ezcDebug::getInstance();
     $this->dbg->reset();
     $this->dbg->setOutputFormatter(new TestReporter());
 }
Example #6
0
 /**
  * Dispatches the message and error type to the correct debug or log
  * function.
  *
  * This function should be used as the set_error_handler from the
  * trigger_error function.
  *
  * Use for example the following code in your application:
  *
  * <code>
  * function debugHandler( $a, $b, $c, $d )
  * {
  *     ezcDebug::debugHandler( $a, $b, $c, $d );
  * }
  *
  * set_error_handler( "debugHandler" );
  * </code>
  *
  * Use trigger_error() to log warning, error, etc:
  *
  * <code>
  * trigger_error( "[Paynet, templates] Cannot load template", E_USER_WARNING );
  * </code>
  *
  * See the PHP documentation of
  * {@link http://php.net/trigger_error trigger_error} for more information.
  *
  * @param int $errno
  * @param string $errstr
  * @param string $errfile
  * @param int $errline
  * @return void
  */
 public static function debugHandler($errno, $errstr, $errfile, $errline)
 {
     $debug = ezcDebug::getInstance();
     $log = $debug->getEventLog();
     preg_match('/^\\s*(?:\\[([^,\\]]*)(?:,\\s(.*))?\\])?\\s*(?:(\\d+):)?\\s*(.*)$/', $errstr, $matches);
     $message = $matches[4] === '' ? false : $matches[4];
     $verbosity = $matches[3] === '' ? false : $matches[3];
     if (strlen($matches[2]) == 0) {
         $category = $matches[1] === '' ? $log->category : $matches[1];
         $source = $log->source;
     } else {
         $category = $matches[2];
         $source = $matches[1];
     }
     $severity = false;
     switch ($errno) {
         case E_USER_NOTICE:
             $severity = ezcLog::NOTICE;
             break;
         case E_USER_WARNING:
             $severity = ezcLog::WARNING;
             break;
         case E_USER_ERROR:
             $severity = ezcLog::ERROR;
             break;
     }
     $debug->log($message, $severity, array('source' => $source, 'category' => $category, 'verbosity' => $verbosity, 'file' => $errfile, 'line' => $errline));
 }
Example #7
0
 public function testDelayedInit()
 {
     ezcBaseInit::setCallback('ezcInitDebug', 'testDelayedInitDebug');
     $dbg = ezcDebug::getInstance();
     $this->assertAttributeEquals(new TestReporter(), 'formatter', $dbg);
 }
Example #8
0
 public static function designJS($files)
 {
     $debugOutput = erConfigClassLhConfig::getInstance()->getSetting('site', 'debug_output');
     $items = explode(';', $files);
     if ($debugOutput == true) {
         $logString = '';
         $debug = ezcDebug::getInstance();
     }
     $filesToCompress = '';
     $instance = erLhcoreClassSystem::instance();
     $extensions = erConfigClassLhConfig::getInstance()->getOverrideValue('site', 'extensions');
     foreach ($items as $path) {
         $fileFound = false;
         /**
          * Check extension folders first
          * */
         foreach ($extensions as $ext) {
             $fileDir = $instance->SiteDir . '/extension/' . $ext . '/design/' . $ext . 'theme/' . $path;
             if (file_exists($fileDir)) {
                 $fileContent = file_get_contents($fileDir);
                 // normalize line feeds
                 $script = str_replace(array("\r\n", "\r"), "\n", $fileContent);
                 // remove multiline comments
                 $script = preg_replace('!(?:\\n|\\s|^)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $script);
                 $script = preg_replace('!(?:;)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', ';', $script);
                 // remove whitespace from start & end of line + singelline comment + multiple linefeeds
                 $script = preg_replace(array('/\\n\\s+/', '/\\s+\\n/', '#\\n\\s*//.*#', '/\\n+/'), "\n", $script);
                 $filesToCompress .= $script . "\n";
                 $fileFound = true;
                 if ($debugOutput == true) {
                     $logString .= "<b>Found IN - " . $fileDir . "</b><br/>";
                 }
                 break;
             } else {
                 if ($debugOutput == true) {
                     $logString .= "Not found IN - " . $fileDir . "<br/>";
                 }
             }
         }
         if ($fileFound == false) {
             foreach ($instance->ThemeSite as $designDirectory) {
                 $fileDir = $instance->SiteDir . 'design/' . $designDirectory . '/' . $path;
                 if (file_exists($fileDir)) {
                     $fileContent = file_get_contents($fileDir);
                     // normalize line feeds
                     $script = str_replace(array("\r\n", "\r"), "\n", $fileContent);
                     // remove multiline comments
                     $script = preg_replace('!(?:\\n|\\s|^)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $script);
                     $script = preg_replace('!(?:;)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', ';', $script);
                     // remove whitespace from start & end of line + singelline comment + multiple linefeeds
                     $script = preg_replace(array('/\\n\\s+/', '/\\s+\\n/', '#\\n\\s*//.*#', '/\\n+/'), "\n", $script);
                     $filesToCompress .= $script . "\n";
                     $fileFound = true;
                     if ($debugOutput == true) {
                         $logString .= "<b>Found IN - " . $fileDir . "</b><br/>";
                     }
                     break;
                 } else {
                     if ($debugOutput == true) {
                         $logString .= "Not found IN - " . $fileDir . "<br/>";
                     }
                 }
             }
         }
     }
     $sys = erLhcoreClassSystem::instance()->SiteDir;
     $fileName = md5($filesToCompress . $instance->WWWDirLang . $instance->Language);
     $file = $sys . 'cache/compiledtemplates/' . $fileName . '.js';
     if (!file_exists($file)) {
         file_put_contents($file, $filesToCompress);
     }
     if ($debugOutput == true) {
         $debug->log($logString, 0, array("source" => "shop", "erLhcoreClassDesign" => "designJS - {$path}"));
     }
     return $instance->wwwDir() . '/cache/compiledtemplates/' . $fileName . '.js';
 }
Example #9
0
 protected function renderViewTemplate($controller)
 {
     $debug = ezcDebug::getInstance();
     $tplConfig = new ezcTemplateConfiguration(SITE_ROOT . "/app", SITE_ROOT . "/tmp");
     $tplConfig->addExtension("CustomDate");
     $tplConfig->addExtension("CustomMath");
     $tplConfig->addExtension("MoneyFormat");
     $tplConfig->addExtension("UrlCreator");
     $tplConfig->disableCache = true;
     $tplConfig->checkModifiedTemplates = true;
     $tpl = new ezcTemplate();
     $tpl->configuration = $tplConfig;
     $send = new ezcTemplateVariableCollection($controller->vars);
     $tpl->send = $send;
     $receive = $tpl->receive;
     //var_dump($controller->vars);
     $result = $tpl->process($controller->templateFile . '.ezt');
     //echo $result;
     $merged = array_merge($send->getVariableArray(), $receive->getVariableArray(), array('result' => $result));
     $layoutTpl = new ezcTemplate();
     $layoutTpl->configuration = $tplConfig;
     $layoutTpl->send = new ezcTemplateVariableCollection($merged);
     $path = 'layouts/' . $controller->layout . '.ezt';
     echo $layoutTpl->process($path);
     //$output = $debug->generateOutput();
     //echo $output;
 }
 public function testParseMessageUnknownSeverity()
 {
     trigger_error('[Source, Category] 23: Message', 42);
     $out = ezcDebug::getInstance()->generateOutput();
     $this->assertEquals('Invalid error type specified', $out[0][0]->message);
     $this->assertEquals(false, $out[0][0]->verbosity);
     $this->assertEquals('DefaultCategory', $out[0][0]->category);
     $this->assertEquals('DefaultSource', $out[0][0]->source);
 }
Example #11
0
<?php

//ini_set( 'include_path', ini_get( 'include_path' ) . ':/htdocs/ezc_trunk/:.' );
ini_set('session.gc_maxlifetime', 864000);
require 'Base/src/ezc_bootstrap.php';
// ezcDbInstance::set( ezcDbFactory::create( 'sqlite://'. dirname( __FILE__ ) . '/share.sqlite' ) );
ezcDbInstance::set(ezcDbFactory::create('mysql://*****:*****@127.0.0.1/UnTrucBien'));
$options = new ezcBaseAutoloadOptions(array('debug' => true));
ezcBase::setOptions($options);
ezcBase::addClassRepository(dirname(__FILE__) . '/lib/share', null, 'share');
ezcBase::addClassRepository(dirname(__FILE__) . '/lib/debug', null, 'debug');
$log = ezcLog::getInstance();
$mapper = $log->getMapper();
$writer = new ezcLogUnixFileWriter("/tmp", "thewire-web.log");
$filter = new ezcLogFilter();
$rule = new ezcLogFilterRule($filter, $writer, true);
$mapper->appendRule($rule);
$reader = new ezcConfigurationIniReader();
$reader->init(dirname(__FILE__), 'settings');
$ini = $reader->load();
if ($ini->getBoolSetting('DevelopmentSettings', 'Debug')) {
    ezcBase::setRunMode(ezcBase::MODE_DEVELOPMENT);
    $debugHandler = ezcDebug::getInstance();
    $debugHandler->setOutputFormatter(new debugHtmlFormatter());
    debugLogger::setHandler($debugHandler);
}
$tc = ezcTemplateConfiguration::getInstance();
$tc->templatePath = dirname(__FILE__) . '/templates';
$tc->compilePath = dirname(__FILE__) . '/cache';
$tc->addExtension("shareTemplateFunctions");
 public function informTest($arrayParam, $object)
 {
     // Issue log message with stacktrace
     ezcDebug::getInstance()->log('informTest() called.', ezcLog::NOTICE, array(), true);
 }