/** * * Log messages (debugging purpose) * @param string $msg * @param int $type (default 2) * @return <boolean/string> */ public function log($msg, $type = 2) { if (class_exists('Object')) { !$this->_Object instanceof Object && ($this->_Object = new Object()); return $this->_Object->log($msg, $type); } return false; }
public static function process($exception) { if (class_exists('TransactionManager')) { TransactionManager::rollback(); } $params = array('class' => $class = get_class($exception), 'message' => $exception->getMessage(), 'file' => str_replace(ROOT, 'ROOT', $exception->getFile()), 'line' => $exception->getLine(), 'trace' => $exception->getTraceAsString()); $textError = self::_text($params); if (Configure::read('debug') == 0) { Object::log($textError); switch (true) { case $class === 'DatabaseError': return Object::cakeError('error503', array(array('code' => 503, 'name' => 'Service Unavailable', 'message' => ''))); case isset($exception->httpCode): $error = $exception->httpCode === 403 ? 'forbidden' : 'error' . $exception->httpCode; return Object::cakeError($error); } return Object::cakeError('error500', array(array('code' => 500, 'name' => 'An Internal Error Has Occurred', 'message' => ''))); } else { if (php_sapi_name() == 'cli') { echo $textError; } else { header('Content-Type: text/html; charset=UTF-8'); echo self::_html($params); } } }
/** * This method writes messages in a log file. * @param String $msg A message to write. * @return Worker */ public function logIt($msg) { if (!is_null($this->logger)) { $this->logger->log(LogLevel::INFO, $msg); } return $this; }
protected function _dispatchService($callback, $params, $options = array()) { $options += array('catchTry' => $this->catchTry, 'logException' => $this->logException); $this->begin(); if ($options['catchTry']) { try { $result = call_user_func_array($callback, $params); } catch (Exception $e) { if ($options['logException']) { Object::log($e->__toString()); } $result = false; } } else { $result = call_user_func_array($callback, $params); } if (!$result) { $this->rollback(); } else { $this->commit(); } return $result; }
/** * This method is called automatically when using the name of the helper directly * * @param string $message * @param string $debugLevel * @return void */ public function direct($message, $debugLevel = Zend_Log::INFO) { $this->logger->log($message, $debugLevel); }
function log($msg, $type = LOG_ERROR) { if (!empty($this->config['nick'])) { $type = $this->config['nick']; } else { $type = 'error'; } parent::log($msg, $type); }
/** * log method * * Record to the log (the head doc block on first load in debug mode) or output the log (call with no params) * * @param mixed $string * @static * @return logs contents if requested, otherwise null * @access public */ public static function log($string = null, $shellObject = null) { if (self::$start === null) { self::$start = microtime(true); } static $log = array(); if ($shellObject) { self::$__Shell =& $shellObject; } if ($string === null) { $settings = self::$settings; ksort($settings); foreach ($settings as $k => &$v) { $v = ' ' . str_pad($k, 15, ' ', STR_PAD_RIGHT) . "\t: " . $v; } $settings[] = ''; $head = array_merge(array('MiCompressor log - (only generated on first load) ' . date("D, M jS Y, H:i:s"), null), $settings); $log = array_merge($head, $log); $return = "/**\r\n * " . implode("\r\n * ", $log) . "\r\n */\r\n"; $log = array(); self::$start = microtime(true); return $return; } if (strpos($string, 'PROBLEM') !== false && class_exists('Object')) { $Object = new Object(); $Object->log($string, 'mi_compressor'); } $time = microtime(true) - self::$start; $msg = str_pad(number_format($time, 3, '.', ''), 6, ' ', STR_PAD_LEFT) . 's ' . $string; if (!empty(self::$__Shell)) { self::$__Shell->out($msg); } $log[] = $msg; }