예제 #1
0
 /**
  * Write log entry
  *
  * @param string  $message
  * @param array   $backtrace
  * @return bool|int
  */
 protected function _log($message, $backtrace = null)
 {
     if (!$this->_debug) {
         return true;
     }
     $data = sprintf("[%s] %s\n", date('r'), $message);
     if ($backtrace) {
         $debug = print_r($backtrace, true);
         $data .= $debug . "\n";
     }
     $data = strtr($data, '<>', '..');
     $filename = Util_Debug::log_filename('sns');
     return @file_put_contents($filename, $data, FILE_APPEND);
 }
 /**
  * Write log entry
  *
  * @param string  $local_path
  * @param string  $remote_path
  * @param string  $error
  * @return bool|int
  */
 function _log($local_path, $remote_path, $error)
 {
     $data = sprintf("[%s] [%s => %s] %s\n", date('r'), $local_path, $remote_path, $error);
     $data = strtr($data, '<>', '..');
     $filename = Util_Debug::log_filename('cdn');
     return @file_put_contents($filename, $data, FILE_APPEND);
 }
예제 #3
0
 /**
  * Log
  *
  * @param string  $msg
  * @return bool
  */
 public static function log($msg)
 {
     $data = sprintf("[%s] [%s] [%s] %s\n", date('r'), $_SERVER['REQUEST_URI'], !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '-', $msg);
     $data = strtr($data, '<>', '..');
     $filename = Util_Debug::log_filename('minify');
     return @file_put_contents($filename, $data, FILE_APPEND);
 }
예제 #4
0
 function debug_shutdown()
 {
     $strings = array();
     foreach ($this->processors as $processor) {
         $strings = $processor->w3tc_footer_comment($strings);
     }
     $request_time_total = microtime(true) - $this->request_time_start;
     $data = sprintf("\n[%s] [%s] [%s]\n", date('r'), $_SERVER['REQUEST_URI'], round($request_time_total, 4)) . implode("\n", $strings) . "\n";
     $data = strtr($data, '<>', '..');
     $filename = Util_Debug::log_filename('dbcache');
     @file_put_contents($filename, $data, FILE_APPEND);
 }
 /**
  * Get from the cache
  *
  * @param string  $id
  * @param string  $group
  * @return mixed
  */
 function get($id, $group = 'transient', $force = false, &$found = null)
 {
     if ($this->_debug) {
         $time_start = Util_Debug::microtime();
     }
     $key = $this->_get_cache_key($id);
     list($fragment_group, $fragment_group_expiration, $fragment_group_global) = $this->_fragment_group($id, $group);
     $internal = isset($this->cache[$fragment_group][$key]);
     if ($internal) {
         $found = true;
         $value = $this->cache[$fragment_group][$key];
     } elseif ($this->_caching && !in_array($group, $this->nonpersistent_groups)) {
         $cache = $this->_get_cache($fragment_group_global);
         $v = $cache->get($key, $fragment_group);
         if (is_array($v) && $v['content'] != null) {
             $found = true;
             $value = $v['content'];
         } else {
             $value = false;
         }
     } else {
         $value = false;
     }
     if ($value === null) {
         $value = false;
     }
     if (is_object($value)) {
         $value = clone $value;
     }
     $this->cache[$fragment_group][$key] = $value;
     $this->cache_total++;
     if ($value !== false) {
         $cached = true;
         $this->cache_hits++;
     } else {
         $cached = false;
         $this->cache_misses++;
     }
     /**
      * Add debug info
      */
     if ($this->_debug) {
         $time = Util_Debug::microtime() - $time_start;
         $this->time_total += $time;
         if (!$group) {
             $group = 'transient';
         }
         $this->debug_info[] = array('id' => $id, 'group' => $group, 'cached' => $cached, 'internal' => $internal, 'data_size' => $value ? strlen(serialize($value)) : '', 'time' => $time);
     }
     return $value;
 }
예제 #6
0
 /**
  * Write log entry
  *
  * @param string  $url
  * @param string  $msg
  * @return bool|int
  */
 function _log($url, $msg)
 {
     if ($this->_debug) {
         $data = sprintf("[%s] [%s] %s\n", date('r'), $url, $msg);
         $data = strtr($data, '<>', '');
         $filename = Util_Debug::log_filename('varnish');
         return @file_put_contents($filename, $data, FILE_APPEND);
     }
     return true;
 }