/** * @param \Exception|\Throwable $exception * @return string */ protected function logBluescreen($exception) { $fileName = $this->tracyLogger->getExceptionFile($exception); if (!isset($this->processedExceptionFileNames[$fileName])) { $this->tracyLogger->logException($exception, $fileName); $this->processedExceptionFileNames[$fileName] = TRUE; } return ltrim(strrchr($fileName, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR); }
public function log($message, $priority = self::INFO) { $parent = parent::log($message, $priority); $checked = array(self::CRITICAL, self::ERROR); if (defined('self::EXCEPTION')) { $checked[] = self::EXCEPTION; } if (in_array($priority, $checked, TRUE)) { $index = NULL; $trace = debug_backtrace(FALSE); if (!Tracy\Helpers::findTrace($trace, 'Tracy\\Debugger::log', $index)) { if (!Tracy\Helpers::findTrace($trace, 'Nette\\Diagnostics\\Debugger::log', $index)) { Tracy\Helpers::findTrace($trace, 'log', $index); } } $errorTrace = $trace[$index + 1]; //get trace for _errorHandler call $exceptionTrace = $trace[$index]; //get trace for _exception or ::log call //if() $exception = NULL; if (isset($errorTrace['args']) && count($errorTrace['args']) == 5) { $exception = new \ErrorException($errorTrace['args'][1], 0, $errorTrace['args'][0], $errorTrace['args'][2], $errorTrace['args'][3]); } elseif (!empty($exceptionTrace['args']) && !empty($exceptionTrace['args'][0]) && $exceptionTrace['args'][0] instanceof \Exception) { $exception = $exceptionTrace['args'][0]; } if ($exception) { $error = Consumerr::addError($exception); if ($error && is_array($message)) { $error->addData('file', Tracy\Debugger::$logDirectory . '/' . substr($message[3], 5)); } } } return $parent; }
/** * @param string $directory * @param BlueScreen $blueScreen */ public function __construct($directory, BlueScreen $blueScreen) { $logDirectoryRealPath = realpath($directory); if ($logDirectoryRealPath === FALSE || !is_dir($directory)) { throw new \Nella\MonologTracy\Tracy\InvalidLogDirectoryException(sprintf('Tracy log directory "%s" not found or is not a directory.', $directory)); } parent::__construct($logDirectoryRealPath, NULL, $blueScreen); }
public function __construct(Monolog\Logger $monolog) { $this->monolog = $monolog; // BC with Nette if (interface_exists('Tracy\\ILogger') && method_exists($this, 'logException')) { parent::__construct(Debugger::$logDirectory, Debugger::$email, Debugger::getBlueScreen()); } $this->directory =& Debugger::$logDirectory; $this->email =& Debugger::$email; }
public function log($message, $priority = self::INFO) { $res = parent::log($message, $priority); if ($priority === self::ERROR || $priority === self::CRITICAL) { if (is_array($message)) { $message = implode(' ', $message); } newrelic_notice_error($message); } return $res; }
public function log($message, $priority = self::INFO) { $res = parent::log($message, $priority); // pouze zprávy, které jsou označené jako chyby if ($priority === self::ERROR || $priority === self::CRITICAL) { if (is_array($message)) { $message = implode(' ', $message); } newrelic_notice_error($message); } return $res; }
/** * @inheritdoc */ public function log($value, $priority = self::INFO) { $logFile = parent::log($value, $priority); $message = $this->messageFactory->create($value, $priority, $logFile); $event = new MessageSendEvent($message, $value, $priority, $logFile); foreach ($this->handlers as $handler) { if (!is_callable($handler)) { throw new HandlerException($handler); } $handler($event); } if (!$event->isCancelled()) { $this->sendSlackMessage($message); } return $logFile; }
/** * @inheritdoc */ public function log($value, $priority = self::INFO) { $logFile = parent::log($value, $priority); $message = ucfirst($priority) . ': '; if ($value instanceof Exception || $value instanceof \Throwable) { // NOTE: backwards compatibility with PHP 5 $message .= $value->getMessage(); } elseif (is_array($value)) { $message .= reset($value); } else { $message .= (string) $value; } if ($logFile && $this->logUrl) { $message .= ' (<' . str_replace('__FILE__', basename($logFile), $this->logUrl) . '|Open log file>)'; } $this->sendSlackMessage($message, $priority); return $logFile; }
/** * Wrapper for log function * @param array $message * @param string $priority * @return bool */ public function log($message, $priority = null) { // If message contains one of ignored messages, shut down foreach (self::$ignoredMessages as $ignoredMessage) { if (strpos($message[1], $ignoredMessage) !== false) { return true; } } // Log to file $response = parent::log($message, $priority); if (in_array($priority, self::$priorities)) { if ($message instanceof \Exception) { \Errbit::instance()->notify($message); } else { \Errbit::instance()->notify(new \Exception($priority . ' ' . $message)); } } return $response; }
/** * @inheritdoc */ public function log($value, $priority = self::INFO) { $logFile = parent::log($value, $priority); $message = ucfirst($priority) . ': '; if ($value instanceof Exception) { $message .= $value->getMessage(); } else { if (is_array($value)) { $message .= reset($value); } else { $message .= (string) $value; } } if ($this->logUrl && $logFile) { $message .= ' (<' . str_replace('__FILE__', basename($logFile), $this->logUrl) . '|Open log file>)'; } $this->sendSlackMessage($message); return $logFile; }
public function log($value, $priority = self::INFO) { $logPath = parent::log($value, $priority); if (!$logPath) { // old version of tracy if (isset($value[3])) { $logFile = trim(substr($value[3], 3)); $logPath = $this->directory . '/' . $logFile; } } $message = ucfirst($priority . ': '); if ($value instanceof Exception) { $message .= $value->getMessage(); $priority = LogLevel::CRITICAL; } else { if (is_array($value) && isset($value[1])) { $message .= $value[1]; } else { $message .= (string) $value; } } if ($this->linkToLogFileFactory && is_callable($this->linkToLogFileFactory)) { $linkToLogFile = call_user_func_array($this->linkToLogFileFactory, [$this, $logPath]); if ($linkToLogFile) { $protocol = 'http://'; if (isset($_SERVER['HTTPS'])) { $protocol = 'https://'; } $message .= ' <a href="' . $protocol . $this->resolveHost() . $linkToLogFile . '">(Open log file)</a>'; } } if (isset($value[2])) { $message .= ' [' . trim(str_replace('@', NULL, $value[2])) . ']'; } else { $message .= ' [' . $this->resolveHost() . ']'; } $this->logger->log($priority, $message); return $logPath; }
/** * @return string */ public function logException($exception, $file = NULL) { return parent::logException($exception, $file); }
public function __construct($directory, array $options) { parent::__construct($directory); $this->options = $options; }
public function __construct($directory, $email = NULL, Tracy\BlueScreen $blueScreen = NULL) { parent::__construct($directory, $email, $blueScreen); $this->mailer = [$this, 'defaultMailer']; }
public function __construct($directory, $email = NULL, BlueScreen $blueScreen = NULL) { parent::__construct($directory, $email, $blueScreen); self::__init(); }
/** * @param $message * @param string $priority * @return null|string */ public function log($message, $priority = self::INFO) { if ($this->enabled) { $exceptionFile = ''; if ($this->directory && is_dir($this->directory)) { // Compability with nette 2.2.0, Tracy\Logger has no getExceptionFile in 2.2.0 if (method_exists($this, 'getExceptionFile')) { $exceptionFile = $message instanceof Exception ? $this->getExceptionFile($message) : null; } else { $exceptionFile = null; } // Compability with nette 2.2.0, Tracy\Logger has no formatLogLine in 2.2.0 if (method_exists($this, 'formatLogLine')) { $line = $this->formatLogLine($message, $exceptionFile); } else { if (is_array($message)) { $message = implode(' ', $message); } $line = preg_replace('#\\s*\\r?\\n\\s*#', ' ', trim($message)); } $file = $this->directory . '/' . strtolower($priority ?: self::INFO) . '.log'; if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { throw new \RuntimeException("Unable to write to log file '{$file}'. Is directory writable?"); } } if ($message instanceof Exception) { $this->raven->captureException($message); if ($this->directory && is_dir($this->directory) && method_exists($this, 'logException')) { $this->logException($message, $exceptionFile); } } else { if (in_array($priority, array(self::ERROR, self::EXCEPTION, self::CRITICAL, self::WARNING), true)) { $this->raven->captureMessage($message, array(), $priority); } } // Compability with nette 2.2.0, Tracy\Logger has no sendEmail in 2.2.0 if (in_array($priority, array(self::ERROR, self::EXCEPTION, self::CRITICAL), true) && method_exists($this, 'sendEmail')) { $this->sendEmail($message); } return $exceptionFile; } else { return parent::log($message, $priority); } }