Writes the log to the Task entity

@param WorkPackage $task
@param string      $log
@return void
@throws TaskQueueServiceException
515555
private function updateTaskLog(WorkPackage $task, $log)
    {
        if ($this->databaseDisabled) {
            return;
        }
        $taskEntity = $task->getTaskEntity();
        if ($taskEntity instanceof Task) {
            $taskEntity->setLog($log);
            //make sure it is stored...
            $this->entityManager->flush($taskEntity);
        } else {
            throw new TaskQueueServiceException("Entity is not of type Task");
        }
    }
1022794
protected function submitTask(Task $task)
    {
        switch ($task->type) {
        case Task::JOB_LOW:
            $type = 'submit_job_low';
            break;
        case Task::JOB_LOW_BACKGROUND:
            $type = 'submit_job_low_bg';
            break;
        case Task::JOB_HIGH_BACKGROUND:
            $type = 'submit_job_high_bg';
            break;
        case Task::JOB_BACKGROUND:
            $type = 'submit_job_bg';
            break;
            case Task::JOB_EPOCH:
            $type = 'submit_job_epoch';
            break;
        case Task::JOB_HIGH:
            $type = 'submit_job_high';
            break;
        default:
            $type = 'submit_job';
            break;
        }

        $arg = $task->arg;

        $params = array(
            'func' => $task->func,
            'uniq' => $task->uniq,
            'arg' => $arg,
        );

        if ($task->type == Task::JOB_EPOCH) {
            $params['epoch'] = $task->epoch;
        }

        $s = $this->getConnection();
        Connection::send($s, $type, $params);

        if (!is_array(Connection::$waiting[(int) $s])) {
            Connection::$waiting[(int) $s] = array();
        }

        array_push(Connection::$waiting[(int) $s], $task);
    }
255193
private function updateTaskStatus(WorkPackage $task, $status)
    {
        if ($this->databaseDisabled) {
            return;
        }
        $taskEntity = $task->getTaskEntity();
        if ($taskEntity instanceof Task) {
            $taskEntity->setStatus($status);
            //make sure it is stored...
            $this->entityManager->flush($taskEntity);
        } else {
            throw new TaskQueueServiceException("Entity is not of type Task");
        }
    }
1243561
public function write(string $level, string $message, array $context)
    {
        $this->logger->log($level, $message, $context);
    }
281522
public function markAsExecuted(ScheduledTask $task, \DateTime $executionDate = null)
    {
        if (empty($executionDate)) {
            $executionDate = new \DateTime();
        }

        $task->setExecutionDate($executionDate);

        $this->om->persist($task);
        $this->om->flush();
    }
990854
private function outputTaskStack() {
        foreach ($this->taskStack as $indent => &$task) {
            list($taskLevel, $taskMessage, $taskContext, $taskOutput) = $task;
            if (!$taskOutput) {
                $this->logInternal($taskLevel, $taskMessage, [self::FIELD_INDENT => $indent] + $taskContext);

                $task[3] = true; // mark task as outputted
            }
        }
    }
72317
public static function add_line(string $log) : string {
        if (empty(self::$taskloginfo)) {
            return $log;
        }

        if (empty(self::$fh)) {
            return $log;
        }

        if (self::is_current_output_buffer()) {
            fwrite(self::$fh, $log);
        }

        return $log;
    }
703900
public void trackTask(final ServiceTaskBase<?> task) {

        LOGGER.trace("track a Task");

        this.serviceTasks.add(task);

        task.setOnCancelled(this.workerHandler);
        task.setOnSucceeded(this.workerHandler);
        task.setOnFailed(this.workerHandler);
    }
1022380
public function onTask($server, $taskId, $srcWorkerId, $data)
    {
        $this->container->make('events')->dispatch('swoole.task', func_get_args());

        try {
            // push websocket message
            if ($this->isWebsocketPushPayload($data)) {
                $this->pushMessage($server, $data['data']);
            // push async task to queue
            } elseif ($this->isAsyncTaskPayload($data)) {
                (new SwooleTaskJob($this->container, $server, $data, $taskId, $srcWorkerId))->fire();
            }
        } catch (Throwable $e) {
            $this->logServerError($e);
        }
    }
750524
public function mergeLog(Log $log)
	{
		/** @var Release $release */
		foreach ($log as $release)
		{
			$name = $release->getName();
			if ($this->hasRelease($name))
			{
				// if it does exist then merge the changes
				$this->mergeRelease($log, $name);
			}
			else
			{
				// If the release does not exist add it
				$this->addRelease($release);
			}
		}
	}
1054712
public function addTask(Task $task): Task
    {
        @trigger_error(sprintf('The %s() method is deprecated since version 0.8. Use create() instead.', __METHOD__), E_USER_DEPRECATED);

        return $this->create($task);
    }
138589
public function write(Log $log)
	{
		if ($this->output === null)
		{
			throw new LogicException('You must specify an IOInterface for output first.');
		}

		$this->output->setContent(
			$this->renderer->render($log)
		);
	}
788059
private void writeTasks(Project project)
   {
      Project.Tasks tasks = m_factory.createProjectTasks();
      project.setTasks(tasks);
      List<Project.Tasks.Task> list = tasks.getTask();

      for (Task task : m_projectFile.getTasks())
      {
         list.add(writeTask(task));
      }
   }
1371109
private void write(final Collection<Writer> writers, final Task task) {
		try {
			Writer writer = task.writer;
			writer.write(task.logEntry);
			if (!writers.contains(writer)) {
				writers.add(writer);
			}
		} catch (Exception ex) {
			InternalLogger.log(Level.ERROR, ex, "Failed to write log entry '" + task.logEntry.getMessage() + "'");
		}
	}
1078126
public function onLog(LogGenericEvent $event)
    {
        if ($event instanceof LogRoleSubscribeEvent) {
            $role = $event->getRole();
            $workspace = $role->getWorkspace();

            if (!empty($workspace)) {
                $this->manager->generateScheduledTasks(
                    $event->getActionKey(),
                    $event->getReceiver(),
                    $workspace,
                    $event->getReceiverGroup(),
                    $role
                );
            }
        } elseif ($event instanceof LogWorkspaceEnterEvent) {
            $user = $this->tokenStorage->getToken()->getUser();

            if ('anon.' !== $user) {
                $this->manager->generateScheduledTasks($event->getAction(), $user, $event->getWorkspace());
            }
        }
    }
1349063
public function log($level, $message, array $context = []) {
        if ($this->compareLevel($level, $this->getMinLevel()) >= 0) {
            $this->outputTaskStack();

            // Increase the level begin tasks if this level is higher.
            foreach ($this->taskStack as &$task) {
                if ($this->compareLevel($level, $task[0]) > 0) {
                    $task[0] = $level;
                }
            }

            $this->logInternal($level, $message, [self::FIELD_INDENT => $this->currentIndent()] + $context);
        }
    }
252072
public function endTask(Task $task)
    {
        if ($task->isShallow()) {
            return;
        }

        $endTime = round(microtime(true) * 1000);
        $millis = $endTime - $this->startTime;
        $seconds = floor($millis / 1000);
        $millis = $millis - $seconds * 1000;
        $taskTime = ($seconds > 0 ? "{$seconds}s " : "") . "{$millis}ms";

        $shouldReplaceTaskMark =
            $this->output->isDecorated() &&
            $this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL &&
            !$this->output->getWasWritten();

        if ($shouldReplaceTaskMark) {
            $this->output->writeln("\r\033[K\033[1A\r<info>✔</info>");
        } else {
            if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
                $this->output->writeln("<info>✔</info> Ok");
            } else {
                $this->output->writeln("<info>✔</info> Ok [$taskTime]");
            }
        }
    }