Exemplo n.º 1
0
/**
 * Creates an instance of a page class
 * @param string $page The name of a RaxanWebPage sub-class
 * @param string $content
 */
function raxan_auto_create($page, $content = null)
{
    // initialize page class
    if ($page) {
        try {
            if (!$content) {
                $content = '';
            }
            $type = substr($content, 0, 5) == '<?xml' ? 'xml' : null;
            $o = new $page($content, null, $type);
            $o->reply();
        } catch (Exception $e) {
            // raise system error event
            $rt = Raxan::triggerSysEvent('system_error', $e);
            if (!$rt) {
                $err = $e->getMessage() . '  Line ' . $e->getLine() . ' in ' . $e->getFile() . "\n" . $e->getTraceAsString() . "\n";
                if (ini_get('display_errors') == 1) {
                    echo "Uncaught Error: " . nl2br($err);
                }
                Raxan::log($err, 'ERROR', 'Uncaught Error');
            }
        }
    }
}
Exemplo n.º 2
0
 /**
  * Adds an entry to the log file
  * @return boolean
  */
 public function log($var, $level = null, $label = null)
 {
     return Raxan::log($var, $level, $label);
 }
Exemplo n.º 3
0
 function testLog()
 {
     $msg = 'Raxan Class Test';
     $t = date('Y-m-d H:i:s', time());
     $file = dirname(__FILE__) . '/logfile.txt';
     file_put_contents($file, '');
     Raxan::config('log.enable', true);
     Raxan::config('log.file', $file);
     // log
     Raxan::log($msg);
     $c = file_get_contents($file);
     $this->compare("INFO \t" . $t . " \t \t" . $msg, trim($c), 'Log file content');
     // log with params
     file_put_contents($file, '');
     Raxan::log($msg, 'ERROR', 'Label');
     $t = date('Y-m-d H:i:s', time());
     $c = file_get_contents($file);
     $this->compare("ERROR \t" . $t . " \t [Label] \t" . $msg, trim($c), 'Log with label params');
 }