コード例 #1
0
function crayon_exception_info($e, $return = TRUE)
{
    $print = '<br/><b>Uncaught ' . get_class($e) . ':</b> ' . $e->getMessage() . CRAYON_BL . '<b>File:</b> ' . CrayonUtil::path_rel($e->getFile()) . CRAYON_BL . '<b>Line:</b> ' . $e->getLine() . CRAYON_BL . '<br/>';
    if ($return) {
        return $print;
    } else {
        echo $print;
    }
}
コード例 #2
0
 public static function log($var = NULL, $title = '', $trim_url = TRUE)
 {
     if ($var === NULL) {
         // Return log
         if (($log = CrayonUtil::file(CRAYON_LOG_FILE)) !== FALSE) {
             return $log;
         } else {
             return '';
         }
     } else {
         try {
             if (self::$file == NULL) {
                 self::$file = @fopen(CRAYON_LOG_FILE, 'a+');
                 if (self::$file) {
                     $header = CRAYON_NL . '[Crayon Syntax Highlighter Log Entry - ' . date('g:i:s A - d M Y') . ']' . CRAYON_NL . CRAYON_NL;
                     fwrite(self::$file, $header);
                 } else {
                     return;
                 }
             }
             // Capture variable dump
             ob_start();
             var_dump($var);
             $buffer = trim(strip_tags(ob_get_clean()));
             // Remove stupid formatting from wampserver
             $buffer = str_replace('&apos;', '"', $buffer);
             $buffer = preg_replace('#^string\\([^\\)]*\\)#mi', 'str', $buffer);
             $title = !empty($title) && is_string($title) ? " [{$title}]" : '';
             // Remove absolute path to plugin directory from buffer
             if ($trim_url) {
                 $buffer = CrayonUtil::path_rel($buffer);
             }
             $write = $title . ' ' . $buffer . CRAYON_NL;
             // If we exceed max file size, truncate file first
             if (filesize(CRAYON_LOG_FILE) + strlen($write) > CRAYON_LOG_MAX_SIZE) {
                 ftruncate(self::$file, 0);
                 fwrite(self::$file, 'The log has been truncated since it exceeded ' . CRAYON_LOG_MAX_SIZE . ' bytes.' . CRAYON_NL . CRAYON_NL);
             }
             clearstatcache();
             fwrite(self::$file, $write, CRAYON_LOG_MAX_SIZE);
         } catch (Exception $e) {
             // Ignore fatal errors
         }
     }
 }
コード例 #3
0
 public static function log($var = NULL, $title = '', $trim_url = TRUE)
 {
     if ($var === NULL) {
         // Return log
         if (($log = CrayonUtil::file(CRAYON_LOG_FILE)) !== FALSE) {
             return $log;
         } else {
             return '';
         }
     } else {
         try {
             if (self::$file == NULL) {
                 self::$file = @fopen(CRAYON_LOG_FILE, 'a+');
                 if (self::$file) {
                     $header = CRAYON_NL . '[Crayon Syntax Highlighter Log Entry - ' . date('g:i:s A - d M Y') . ']' . CRAYON_NL . CRAYON_NL;
                     fwrite(self::$file, $header);
                 } else {
                     return;
                 }
             }
             // Capture variable dump
             $buffer = trim(strip_tags(var_export($var, true)));
             $title = !empty($title) ? " [{$title}]" : '';
             // Remove absolute path to plugin directory from buffer
             if ($trim_url) {
                 $buffer = CrayonUtil::path_rel($buffer);
             }
             $write = $title . ' ' . $buffer . CRAYON_NL;
             // If we exceed max file size, truncate file first
             if (filesize(CRAYON_LOG_FILE) + strlen($write) > CRAYON_LOG_MAX_SIZE) {
                 ftruncate(self::$file, 0);
                 fwrite(self::$file, 'The log has been truncated since it exceeded ' . CRAYON_LOG_MAX_SIZE . ' bytes.' . CRAYON_NL . CRAYON_NL);
             }
             clearstatcache();
             fwrite(self::$file, $write, CRAYON_LOG_MAX_SIZE);
         } catch (Exception $e) {
             // Ignore fatal errors during logging
         }
     }
 }