/** * @inheritdoc */ public function log($level, $message, array $context = array()) { if ($this->isLevelLessThanMinimum($level)) { return; } $this->logger->log($level, $message, $context); }
/** * @param string $langPackDir language pack dir in temp folder * @param string $projectNamespace e.g. Oro, OroCRM, etc * @param string $outputFormat xml, yml, etc * @param string $locale en, en_US, fr, etc */ public function dump($langPackDir, $projectNamespace, $outputFormat, $locale) { $this->preloadExistingTranslations($locale); foreach ($this->bundles as $bundle) { // skip bundles from other projects if ($projectNamespace != $this->getBundlePrefix($bundle->getNamespace())) { continue; } $this->logger->log(LogLevel::INFO, ''); $this->logger->log(LogLevel::INFO, sprintf('Writing files for <info>%s</info>', $bundle->getName())); /** @var MessageCatalogue $currentCatalogue */ $currentCatalogue = $this->getCurrentCatalog($locale, $bundle->getName()); $extractedCatalogue = $this->extractViewTranslationKeys($locale, $bundle->getPath()); $operation = new MergeOperation($currentCatalogue, $extractedCatalogue); $messageCatalogue = $operation->getResult(); $isEmptyCatalogue = $this->validateAndFilter($messageCatalogue); if (!$isEmptyCatalogue) { $translationsDir = $langPackDir . DIRECTORY_SEPARATOR . $bundle->getName() . DIRECTORY_SEPARATOR . 'translations'; $this->filesystem->mkdir($translationsDir); $this->writer->writeTranslations($messageCatalogue, $outputFormat, ['path' => $translationsDir]); } else { $this->logger->log(LogLevel::INFO, ' - no files generated'); } } }
/** * Write a message to the log or skip over it if the message is null * * @param string $logLevel * @param string|null $message */ protected function log($logLevel, $message) { if ($message === null) { return; } $this->logger->log($logLevel, $message); }
public function __construct($message = \null, $code = \null, $previous = \null) { parent::__construct($message, $code, $previous); if (static::$logger !== \null) { static::$logger->log(LogLevel::ALERT, $message, array('code' => $this->getCode(), 'message' => $this->getMessage(), 'file' => $this->getFile(), 'line' => $this->getLine(), 'type' => 'exceptions')); } }
/** * {@inheritdoc} */ public function log($level, $message, array $context = array()) { if ($this->logger) { $this->logger->log($level, $message, $context); } return $this; }
public function log($message, array $context = array(), $level = LogLevel::DEBUG) { if (!isset($this->logger)) { return; } $this->logger->log($level, $message, $context); }
/** * @param \Neoxygen\NeoClient\Event\HttpClientPreSendRequestEvent $event */ public function onPreHttpRequestSend(HttpClientPreSendRequestEvent $event) { $conn = $event->getRequest()->getConnection(); $request = $event->getRequest(); $mode = $request->hasQueryMode() ? $request->getQueryMode() : 'ASSUMED WRITE'; $this->logger->log('debug', sprintf('Sending "%s" request to the "%s" connection', $mode, $conn)); }
/** * Logs with an arbitrary level. * * @param mixed $level * @param string $message * @param array $context * @return null */ public function log($level, $message, array $context = array()) { if (null === $this->logger) { return; } $add = true; $stackTrace = $this->getStackTrace(); if (null !== $this->stopwatch) { $trace = debug_backtrace(); $method = $trace[3]['function']; $watch = 'Propel Query ' . (count($this->queries) + 1); if ('prepare' === $method) { $this->isPrepared = true; $this->stopwatch->start($watch, 'propel'); $add = false; } elseif ($this->isPrepared) { $this->isPrepared = false; $event = $this->stopwatch->stop($watch); } } // $trace[2] has no 'object' key if an exception is thrown while executing a query if ($add && isset($event) && isset($trace[2]['object'])) { $connection = $trace[2]['object']; $this->queries[] = array('sql' => $message, 'connection' => $connection->getName(), 'time' => $event->getDuration() / 1000, 'memory' => $event->getMemory(), 'stackTrace' => $stackTrace); } $this->logger->log($level, $message, $context); }
/** * Записывает сообщение в лог. * @param string $level уровень критичности сообщения * @param string $message сообщение, поддерживает плейсхолдеры в формате {placeholder} * @param array $placeholders список плейсхолдеров * @return $this */ protected function log($level, $message, array $placeholders = []) { if ($this->traitLogger) { $this->traitLogger->log($level, $message, $placeholders); } return $this; }
/** * Adds the message prefix and invokes the logger->log() method. * * @param mixed $level * @param string $message * @param array $context * @return void */ private function log($level, $message, array $context = array()) { // Using a falsy level disables logging if ($level) { $this->logger->log($level, $this->prefix . $message, $context); } }
/** * {@inheritdoc} */ public function getForm($formClass) { $args = func_get_args(); array_shift($args); if (!class_exists($formClass)) { $this->logger->log(LogLevel::CRITICAL, "Form class '@class' does not exists", ['@class' => $formClass]); return []; } if (!method_exists($formClass, 'create')) { $this->logger->log(LogLevel::CRITICAL, "Form class '@class' does not implements ::create()", ['@class' => $formClass]); return []; } // God, I do hate Drupal 8... $form = call_user_func([$formClass, 'create'], $this->container); if (!$form instanceof FormInterface) { $this->logger->log(LogLevel::CRITICAL, "Form class '@class' does not implement \\Drupal\\Core\\Form\\FormInterface", ['@class' => $formClass]); return []; } $formId = $form->getFormId(); $data = []; $data['build_info']['args'] = $args; $formState = new FormState($data); $formState->setFormObject($form); $this->formMap[$formId] = [$form, $formState]; return drupal_build_form($formId, $data); }
/** * Log payment message, prepending payment bundle name if set. * * @param string $level Level * @param string $message Message to log * @param string $paymentMethod Payment method * @param array $context Context * * @return PaymentLogger Self object */ public function log($level, $message, $paymentMethod, array $context = []) { if (!$this->active) { return $this; } $this->logger->log($level, "[{$paymentMethod}] - {$message}", $context); return $this; }
/** * handleException * * Handles Exceptions * * @access public * @param Exception $exception * @return void * @todo Make default / fallback log level configurable **/ public function handleException(Exception $exception) { if (method_exists($exception, "getSeverityLevel")) { $this->logger->log($exception->getSeverityLevel(), $exception->getMessage(), $this->getExceptionContext($exception)); } else { $this->logger->critical($exception->getMessage(), $this->getExceptionContext($exception)); } }
/** * {@inheritDoc} */ public function handle(array $record) { if (!$this->isHandling($record)) { return false; } $this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']); return false === $this->bubble; }
/** * Tests sending a mail to two recipients. * * @covers ::execute */ public function testSendMailToTwoRecipients() { $to = ['*****@*****.**', '*****@*****.**']; $this->action->setContextValue('to', $to)->setContextValue('subject', 'subject')->setContextValue('message', 'hello'); $params = ['subject' => 'subject', 'message' => 'hello']; $this->mailManager->mail('rules', 'rules_action_mail_' . $this->action->getPluginId(), implode(', ', $to), LanguageInterface::LANGCODE_SITE_DEFAULT, $params, NULL)->willReturn(['result' => TRUE])->shouldBeCalledTimes(1); $this->logger->log(LogLevel::NOTICE, SafeMarkup::format('Successfully sent email to %to', ['%to' => implode(', ', $to)]))->shouldBeCalledTimes(1); $this->action->execute(); }
/** * Handle the message by letting the next middleware handle it. If no handler is defined for this message, then * it is published to be processed asynchronously * * @param object $message * @param callable $next */ public function handle($message, callable $next) { try { $next($message); } catch (UndefinedCallable $exception) { $this->logger->log($this->logLevel, 'No message handler found, trying to handle it asynchronously', ['type' => get_class($message)]); $this->publisher->publish($message); } }
/** * Logs a request which is being delayed by a specified amount of time. * * @param RequestInterface The request being delayed. * @param float $delay The amount of time that the request is delayed for. */ protected function log(RequestInterface $request, $delay) { if (isset($this->logger)) { $level = $this->getLogLevel($request, $delay); $message = $this->getLogMessage($request, $delay); $context = compact('request', 'delay'); $this->logger->log($level, $message, $context); } }
/** * {@inheritdoc} */ public function __invoke(Request $request, Response $response, callable $next) { $result = call_user_func($next, $request, $response); if ($result instanceof Response) { $response = $result; } $this->logger->log($this->level, call_user_func($this->formatter, $request, $response), ['request' => $request, 'response' => $request]); return $response; }
/** * {@inheritdoc} */ public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL) { $messages = (array) $messages; foreach ($messages as $message) { $this->logger->log(200, strip_tags($message)); } reset($messages); parent::write($messages, $newline, $options); }
/** * {@inheritDoc} */ public function append(ViolationInterface $violation, $severity = DestinationInterface::SEVERITY_ERROR) { $message = $violation->getMessage(); $parameters = $violation->getParameters(); if ($this->isConsole) { $parameters = $this->prepareContext($parameters); } $this->logger->log($this->mapLogLevel($severity), $message, $parameters); }
public function handle($message, callable $next) { $messageSubscribers = $this->messageSubscribersResolver->resolve($message); foreach ($messageSubscribers as $messageSubscriber) { $this->logger->log($this->level, 'Started notifying a subscriber', ['subscriber' => $messageSubscriber]); call_user_func($messageSubscriber, $message); $this->logger->log($this->level, 'Finished notifying a subscriber', ['subscriber' => $messageSubscriber]); } $next($message); }
/** * @param string $level * @param ResponseInterface $response * @param array $context */ public function logResponse($level, ResponseInterface $response, array $context = array()) { $msg = "[FacebookAPI] [Response] \n"; $msg .= $response->getStatusCode() . ' '; foreach ($response->getHeaders() as $name => $value) { $msg .= "\r\n{$name}: " . $value; } $message = "{$msg}\r\n\r\n" . $response->getBody(); $this->logger->log($level, $message, $context); }
/** * @param ServerRequest $request * @param Response $response * @param callable $next * * @return ResponseInterface */ public function __invoke(ServerRequest $request, Response $response, callable $next) { $outResponse = $next($request, $response); $messages = $this->formatter->format($request, $outResponse); if (!is_string($messages)) { throw new \UnexpectedValueException(sprintf('%s must return string', HttpMessagesFormatter::class)); } $this->logger->log($this->level, $messages); return $outResponse; }
/** * Log payment message, prepending payment bundle name if set * * @param string $message Message to log * @param array $context Context * * @return PaymentLogger Self object */ public function log($message, array $context = array()) { if ($this->active) { if ($this->paymentBundle) { $message = '[' . $this->paymentBundle . '] ' . $message; } $this->logger->log($this->level, $message, $context); } return $this; }
/** * Log message. * * @param string $type * @param string $message * * @return void */ protected function logMessage($type, $message) { if (null === $this->logger) { return; } $logLevel = Logger::INFO; if (Process::ERR === $type) { $logLevel = Logger::ERROR; } $this->logger->log($logLevel, $message); }
/** * {@inheritDoc} */ public function log($level, $message) { if ($this->logger instanceof LoggerInterface) { $this->logger->log($level, $message); } else { $skip = ['debug', 'info']; if (!in_array($level, $skip)) { trigger_error($message, E_USER_NOTICE); } } }
/** * @priority MONITOR * @param ProxyResponseEvent $event */ public function onProxyResponse(ProxyResponseEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); $logLine = $this->getLogLine($this->getLogData($request, $response)); $level = LogLevel::INFO; if (!$response || !$response->isSuccessful()) { $level = LogLevel::WARNING; } $this->logger->log($level, $logLine); }
/** * Writes message to the log * * @fixme Do formatting with a Monolog formatter * @param string $id * @param string $status * @param string $data * @param string $log_level One of the constants defined in @see \Psr\Log\LogLevel */ protected function log($id = '', $status = '', $data = '', $log_level = LogLevel::INFO) { // format the message $msg = '"' . date('c') . '"'; $msg .= "\t" . '"' . $id . '"'; $msg .= "\t" . '"' . $status . '"'; $msg .= "\t" . $data . "\n"; // replace tabs with spaces - maybe do this universally? cuz who needs tabs. $msg = str_replace("\t", " ", $msg); $this->transaction_logger->log($log_level, $msg); }
/** * Logs the LogEvent to the logger instance. * * @param LogEvent $event */ public function onLogEvent(LogEvent $event) { $context = $event->getContext(); $context['event.name'] = $event->getEventNameContext(); $eventSubscriberClassName = get_class($event->getEventSubscriberContext()); if (strrpos($eventSubscriberClassName, '\\') !== false) { $eventSubscriberClassName = substr($eventSubscriberClassName, strrpos($eventSubscriberClassName, '\\') + 1); } $context['event.task.name'] = $eventSubscriberClassName; $this->logger->log($event->getLevel(), $event->getMessage(), $context); }
public static function log($level, $message, $context) { if (is_null(self::$logger)) { return false; } try { return self::$logger->log($level, $message, $context); } catch (Exception $e) { error_log("Issue logging with configured logger. {$e}"); return false; } }