@param Message $message

@throws Exception
@throws \Exception
553971
public function logMessage(Message $message): void
    {
        if (in_array($message->getLevel(), $this->config['log']) && !$this->inserting) {
            if ($this->insertFn !== null) {
                $insert = call_user_func($this->insertFn, $message, $this->config);

                if ($insert !== null) {

                    if (!is_object($insert)) {
                        throw new Exception('\'get_insert_fn\' function must return an instance of Insert; instead got type of ' . gettype($insert));
                    } else {
                        // it is object, but what type
                        if (!($insert instanceof Insert)) {
                            throw new Exception('\'get_insert_fn\' function must return an instance of Insert; instead got instance of ' . get_class($insert));
                        }
                    }

                }
            } else {
                $data = [
                  'time' => $message->getTime()->format('Y-m-d H:i:s'),
                  'level' => $message->getLevel(),
                  'who' => $message->getWho() ?? Log::getWho(),
                  'message' => $message->getMessage()
                ];

                $insert = new Insert($this->getTableName(), $data, $this->getAdapterConnection());
            }

            if ($insert !== null) {
                $this->inserting = true;

                try {

                    Log::temporaryDisable();
                    $insert->exec();

                } catch (\Exception $e) {
                    throw $e;

                } finally {
                    Log::restoreTemporaryDisablement();
                    // @todo write tests for failures
                    $this->inserting = false;
                }
            }
        }
    }
576255
protected function logError($message)
    {
        if ($this->logger instanceof LoggerInterface) {
            $this->logger->error($message);
        } else {
            error_log($message);
        }
    }
936751
public function send(Message $message) : void
    {
        $sender = $this->smtp['sender'];
        $recipients = is_array($sender['to']) ? $sender['to'] : [$sender['to']];

        $message->setFrom($sender['email'], $sender['name']);

        foreach ($recipients as $to)
        {
            $message->addTo($to);
        }

        $mailer = new \Nette\Mail\SmtpMailer($this->smtp['config']);
        $mailer->send($message);
    }
1008115
protected function log($message): void
    {
        if ($this->logger !== null) {
            $this->logger->log($message);
        }
    }
813583
protected function addDisplayException($message)
    {
        $exception = oxNew(\OxidEsales\Eshop\Core\Exception\ExceptionToDisplay::class);
        $exception->setMessage($message);
        \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($exception);
    }
371169
public function load(Message $message) : ?Message
    {
        $aggregateIdentifiers = [];
        $expectedVersion = null;

        foreach ($this->aggregateIdentifierMapping as $aggregateIdentifierName => $aggregateIdentifierMappingName) {
            $aggregateIdentifiers[$aggregateIdentifierName] = $this->isFactoryMethod ? null : $this->propertyReaderAccessor->getPropertyValue(PropertyPath::createWith($aggregateIdentifierMappingName), $message->getPayload());
        }

        $aggregate = null;
        if (!$this->isFactoryMethod) {

            foreach ($aggregateIdentifiers as $identifierName => $aggregateIdentifier) {
                if (is_null($aggregateIdentifier)) {
                    throw AggregateNotFoundException::create("Aggregate identifier {$identifierName} definition found, but is null. Can't load aggregate {$this->aggregateClassName} to call {$this->aggregateMethod}.");
                }
            }

            $expectedVersion = $this->expectedVersionName ? $this->propertyReaderAccessor->getPropertyValue(PropertyPath::createWith($this->expectedVersionName), $message->getPayload()) : null;
            if ($this->expectedVersionName && !$expectedVersion) {
                throw InvalidArgumentException::create("Aggregate {$this->aggregateClassName}:{$this->aggregateMethod} has defined version locking, but no version during command handling was provided");
            }

            $aggregate = is_null($this->expectedVersionName)
                ? $this->aggregateRepository->findBy($aggregateIdentifiers)
                : $this->aggregateRepository->findWithLockingBy($aggregateIdentifiers, $expectedVersion);

            if (!$aggregate && $this->filterOutOnNotFound) {
                return null;
            }
        }

        $messageBuilder = MessageBuilder::fromMessage($message);
        if ($aggregate) {
            $messageBuilder = $messageBuilder->setHeader(AggregateMessage::AGGREGATE_OBJECT, $aggregate);
        }
        if ($expectedVersion) {
            $messageBuilder = $messageBuilder->setHeader(AggregateMessage::EXPECTED_VERSION, $expectedVersion);
        }

        if (!$message->getHeaders()->containsKey(MessageHeaders::REPLY_CHANNEL)) {
            $messageBuilder = $messageBuilder
                                ->setReplyChannel(NullableMessageChannel::create());
        }

        return $messageBuilder
            ->setHeader(AggregateMessage::CLASS_NAME, $this->aggregateClassName)
            ->setHeader(AggregateMessage::METHOD_NAME, $this->aggregateMethod)
            ->setHeader(AggregateMessage::AGGREGATE_ID, $aggregateIdentifiers)
            ->setHeader(AggregateMessage::IS_FACTORY_METHOD, $this->isFactoryMethod)
            ->setHeader(AggregateMessage::CALLING_MESSAGE, $message)
            ->build();
    }
909255
private function logException($message, $exception)
    {
        return $this->app['logger.system']->error(
            $message . ': ' . $exception->getMessage(),
            ['event' => 'exception', 'exception' => $exception]
        );
    }
32374
public static function forMessage(Message $message)
    {
        $exception = new static('Missing publisher for message of class ' . get_class($message));
        $exception->tacticianMessage = $message;

        return $exception;
    }
775453
public function error($message): void
	{
		$message = $this->logMessToArray($message);
		$this->log(array_merge(['SEVERITY' => 'ERROR'], $message));
	}
1069468
public function run(TestMessage $message)
    {
        $this->environment->load($this->reader);
        $this->message = $message;
        $this->listen($this->environment->getEventEmitter());
        $context = Context::getInstance();
        $this->looper->loop($context, $this->environment, $message);
    }
914942
protected function writeToExceptionLogFile($message)
    {
        if (is_writable($this->exceptionLogFile) || is_writable(dirname($this->exceptionLogFile))) {
            $message = sprintf('[%s] %s' . PHP_EOL, (new \DateTime())->format(\DateTime::ISO8601), $message);
            @file_put_contents($this->exceptionLogFile, $message, FILE_APPEND);
        }
    }
194653
public function setError(?string $message = null) : void
    {
        $this->is_valid = false;
        $this->error = (null === $message) ? $this->default_error : $message;
    }
1181289
protected function log(
        $message, $source = null, $level = E_NOTICE, $data = null
    )
    {
        if (!($this->evtManager instanceof Manager)) {
            $e = new ExceptionExtended(sprintf(
                "%s::\$evtManager isn't instance of %s",
                get_class($this), Manager::class
            ));
            $e->setData($data);
            throw $e;
        }
        if (is_null($source)) {
            $source = ":missed:";
        }
        $args = new Args([
            'message' => $message,
            'source'  => $source,
            'level'   => (int)$level,
        ]);
        $this->evtManager->fire(':log:', $args);
    }
186316
private function throwException($message,array $stackTrace , $error = true )
    {
        $this->exception($message,$stackTrace,$error);
    }
22511
public function send(Message $message) : void
    {
        $destination = $this->getRedirectURL($message);
        Utils::getContainer()->redirect($destination);
    }
403146
public function logMessage($message)
    {
        $this->logger->info(strip_tags($message));

        if ($this->sendToBrowser) {
            $this->sendMessageToBrowser($message);
        }

        if ($this->sendToCli) {
            $this->sendMessageToCli($message);
        }
    }
486238
public function delete($message)
    {
        if (!$message instanceof QueueMessage) {
            $msg = new QueueMessage();
            $msg->setId($message);
        }

        $this->driver->delete($message);

        $message->isDeleted(true);
    }