Action - Get the latest deploy log

@return string
771694
public function deploylog(SS_HTTPRequest $request) {
		$params = $request->params();
		$deployment = DNDeployment::get()->byId($params['Identifier']);

		if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404);
		if(!$deployment->canView()) return Security::permissionFailure();

		$environment = $deployment->Environment();
		$project = $environment->Project();

		if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy");
		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy");

		$log = $deployment->log();
		if($log->exists()) {
			$content = $log->content();
		} else {
			$content = 'Waiting for action to start';
		}

		$sendJSON = (strpos($request->getHeader('Accept'), 'application/json') !== false)
			|| $request->getExtension() == 'json';


		$content = preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n", $content);
		if($sendJSON) {
			$this->response->addHeader("Content-type", "application/json");
			return json_encode(array(
				'status' => $deployment->ResqueStatus(),
				'content' => $content,
			));

		} else {
			$this->response->addHeader("Content-type", "text/plain");
			return $content;
		}

	}
5787
public function log()
	{
		$mode      = $this->output->getMode();
		$length    = ($this->arguments->getOpt('length')) ? (int)$this->arguments->getOpt('length') : 20;
		$start     = ($this->arguments->getOpt('start')) ? (int)$this->arguments->getOpt('start') : null;
		$upcoming  = $this->arguments->getOpt('include-upcoming');
		$installed = ($this->arguments->getOpt('exclude-installed')) ? false : true;
		$search    = ($this->arguments->getOpt('search')) ? $this->arguments->getOpt('search') : null;
		$format    = '%an: %s';
		$count     = $this->arguments->getOpt('count');

		if ($mode == 'minimal')
		{
			$format = '%H||%an||%ae||%ad||%s';
		}

		$logs = $this->mechanism->log($length, $start, $upcoming, $installed, $search, $format, $count);

		if ($count)
		{
			$this->output->addLine($logs);
			return;
		}

		if ($mode != 'minimal')
		{
			$output = array();
			foreach ($logs as $log)
			{
				$output[] = array('message'=>$log);
			}

			$this->output->addLinesFromArray($output);
		}
		else
		{
			if (is_array($logs) && count($logs) > 0)
			{
				foreach ($logs as $log)
				{
					$entry = array();
					$parts = explode('||', $log);
					$entry[$parts[0]] = array(
						'name'    => $parts[1],
						'email'   => $parts[2],
						'date'    => $parts[3],
						'subject' => $parts[4]
					);

					$this->output->addLine($entry);
				}
			}
		}
	}
864747
public function getLastCommitDate()
    {
        $process = new Process('git log -n1 --pretty=%ci HEAD', $this->directory);

        if ($process->run() != 0) {
            throw new \RuntimeException('Can\'t run git log. You must ensure that git binary is available.');
        }

        $date = new \DateTime(trim($process->getOutput()));
        $date->setTimezone(new \DateTimeZone('UTC'));

        return $date->format('Y-m-d H:i:s');
    }
672366
protected function getLog()
    {
        if ($this->log == null) {
            $this->log = Tlog::getNewInstance();

            $logFilePath = $this->getLogFilePath();

            $this->log->setPrefix("#LEVEL: #DATE #HOUR: ");
            $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
            $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath);
            $this->log->setLevel(Tlog::INFO);
        }

        return $this->log;
    }
269674
protected function enqueueDeployment() {
		$environment = $this->Environment();
		$project = $environment->Project();
		$log = $this->log();

		$args = array(
			'environmentName' => $environment->Name,
			'sha' => $this->SHA,
			'repository' => $project->LocalCVSPath,
			'logfile' => $this->logfile(),
			'projectName' => $project->Name,
			'env' => $project->getProcessEnv(),
			'deploymentID' => $this->ID,
			'leaveMaintenacePage' => $this->LeaveMaintenacePage
		);

		if(!$this->DeployerID) {
			$this->DeployerID = Member::currentUserID();
		}

		if($this->DeployerID) {
			$deployer = $this->Deployer();
			$message = sprintf(
				'Deploy to %s initiated by %s (%s), with IP address %s',
				$environment->getFullName(),
				$deployer->getName(),
				$deployer->Email,
				Controller::curr()->getRequest()->getIP()
			);
			$log->write($message);
		}

		return Resque::enqueue('deploy', 'DeployJob', $args, true);
	}
830534
public function getVersionLogComments()
    {
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        $updates = [];
        $ga = $db->fetchAll(
            'SELECT fvUpdateTypeID, fvUpdateTypeAttributeID FROM FileVersionLog WHERE fID = ? AND fvID = ? ORDER BY fvlID ASC',
            [$this->getFileID(), $this->getFileVersionID()]
        );
        foreach ($ga as $a) {
            switch ($a['fvUpdateTypeID']) {
                case self::UT_REPLACE_FILE:
                    $updates[] = t('File');
                    break;
                case self::UT_TITLE:
                    $updates[] = t('Title');
                    break;
                case self::UT_DESCRIPTION:
                    $updates[] = t('Description');
                    break;
                case self::UT_TAGS:
                    $updates[] = t('Tags');
                    break;
                case self::UT_CONTENTS:
                    $updates[] = t('File Content');
                    break;
                case self::UT_RENAME:
                    $updates[] = t('File Name');
                    break;
                case self::UT_EXTENDED_ATTRIBUTE:
                    $val = $db->fetchColumn(
                        'SELECT akName FROM AttributeKeys WHERE akID = ?',
                        [$a['fvUpdateTypeAttributeID']]
                    );
                    if ($val !== false) {
                        $updates[] = $val;
                    }
                    break;
            }
        }

        return array_values(array_unique($updates));
    }
1166683
public function getCurrentLogFilePath()
    {
        $rotateTimeMark = "";
        if ($this->rotateTimeFormat !== null) {
            $rotateTimeMark .= "-" . date($this->rotateTimeFormat);
        }

        if (is_callable($this->prefix)) {
            $prefix = call_user_func_array($this->prefix, []);
            // not check prefix here, let user ensure this correctness
        } else {
            $prefix = $this->prefix;
        }
        return $this->targetLogDir . '/log' . (empty($this->prefix) ? '' : "-" . $prefix) . $rotateTimeMark . '.log';
    }
257270
protected function get_legacy_logdata() {
        $user = $this->get_record_snapshot('user', $this->relateduserid);
        $logmessage = get_string('unlocksubmissionforstudent', 'assign', array('id' => $user->id, 'fullname' => fullname($user)));
        $this->set_legacy_logdata('unlock submission', $logmessage);
        return parent::get_legacy_logdata();
    }
43566
public function lastUpdatedDate() {
    $directory = $this->environment->getHooksDirectory();
    $hooks_file = "$directory/hooks_processed.php";
    if (file_exists($hooks_file)) {
      $timestamp = filemtime($hooks_file);
      return $timestamp;
    }
  }
645736
protected function getResourceLog()
    {
        if (($log = \Arbit\VCSWrapper\Cache\Manager::get($this->path, $this->currentVersion, 'log')) !== false) {
            return $log;
        }

        $version = $this->currentVersion !== null ? $this->currentVersion : 'HEAD';

        $process = new \Arbit\VCSWrapper\CvsCli\Process();
        $process
            ->workingDirectory($this->root)
            ->redirect(\Arbit\VCSWrapper\CvsCli\Process::STDERR, \Arbit\VCSWrapper\CvsCli\Process::STDOUT)
            ->argument('log')
            ->argument('-r:' . $version)
            ->argument('.' . $this->path)
            ->execute();


        $log = array();

        $regexp = '((?# Get revision number)
                   revision\s+(?P<revision>[\d\.]+)(\r\n|\r|\n)
                   (?# Get commit date)
                   date:\s+(?P<date>[^;]+);\s+
                   (?# Get commit author)
                   author:\s+(?P<author>[^;]+);\s+
                   (?# Skip everything else)
                   [^\n\r]+;(\r\n|\r|\n)
                   (branches:\s+[^\n\r]+;(\r\n|\r|\n))?
                   (?# Get commit message)
                   (?P<message>[\r\n\t]*|.*)$)xs';

        // Remove closing equal characters
        $output = rtrim(substr(rtrim($process->stdoutOutput), 0, -77));
        // Split all log entries
        $rawLogs = explode('----------------------------', $output);
        $rawLogs = array_map('trim', $rawLogs);
        foreach ($rawLogs as $rawLog) {
            if (preg_match($regexp, $rawLog, $match) === 0) {
                continue;
            }

            $date     = strtotime($match['date']);
            $revision = $match['revision'];
            $logEntry = new \Arbit\VCSWrapper\LogEntry($revision, $match['author'], $match['message'], $date);

            $log[$revision] = $logEntry;
        }

        $log  = array_reverse($log);
        $last = end($log);

        $this->currentVersion = $last->version;
        \Arbit\VCSWrapper\Cache\Manager::cache($this->path, $this->currentVersion, 'log', $log);

        return $log;
    }
126863
public static function lastBuilt()
    {
        $file = TEMP_PATH
            . DIRECTORY_SEPARATOR
            . 'database-last-generated-'
            . str_replace(array('\\','/',':'), '.', Director::baseFolder());

        if (file_exists($file)) {
            return filemtime($file);
        }
        return null;
    }
128660
public function getCronLogfile()
    {
        if (! ($this->offsetExists('cron') && isset($this->cron['logfile']))) {
            return null;
        }

        $file = trim($this->cron['logfile']);
        if (\MUtil_File::isRootPath($file)) {
            return $file;
        }
        return GEMS_ROOT_DIR . '/var/logs/' . $file;
    }
1328718
public function getCurrentDeployment()
    {
        $deployment = EnvironmentDeployment::get('current', $this->getUri() . '/deployments', $this->client);
        if (!$deployment) {
            throw new EnvironmentStateException('Current deployment not found', $this);
        }

        return $deployment;
    }
1093705
public function getLastLoggedAtAttribute()
    {
        $lastLogin = Logs::where('user_id', $this->id)
                ->where('name', 'like', 'USERAUTHLISTENER_ONUSERLOGIN')
                ->orderBy('created_at', 'desc')
                ->get(['created_at'])
                ->first();

        return ($lastLogin) ? $lastLogin->created_at->diffForHumans() : 'never';
    }
804352
public function showLogView()
    {
        $this->subMenu['log']['active'] = true;

        $log = Log::getLogger();

        $logContents = '';

        collect($log->getHandlers())->reject(function ($handler) {
            return $handler instanceof SyslogHandler;
        })->each(function ($handler) use (&$logContents, $log) {
            if (file_exists($path = $log->getHandlers()[0]->getUrl())) {
                $logContents = file_get_contents($path);
            }
        });

        return View::make('dashboard.settings.log')->withLog($logContents)->withSubMenu($this->subMenu);
    }
451004
protected function continueDeploy() {
		$this->log("Checking status of {$this->Title}...");

		// Skip deployment for dry run
		if($this->Pipeline()->DryRun) {
			$this->log("[Skipped] Checking progress of deployment");
			$this->finish();
			return !$this->isFailed();
		}

		// Get related deployment
		$deployment = $this->Pipeline()->CurrentDeployment();
		if(empty($deployment) || !$deployment->exists()) {
			$this->log("Missing deployment for in-progress {$this->Title}");
			$this->markFailed();
			return false;
		}

		// Check finished state
		$status = $deployment->ResqueStatus();
		if($this->checkResqueStatus($status)) {
			$this->finish();
		}
		return !$this->isFailed();
	}
1303922
public function getDeploymentRevision()
    {
        if ($this->version === false) {

            $version = $this->cache->get('DeploymentRevision');

            if ($version === false) {
                $version = $this->versionDao->getSystemVersion();

                if ($version === false)
                    $version = $this->incrementDeploymentRevision('Initial system version');

                $this->cache->put('DeploymentRevision', $version, 0);
            }

            $this->version = $version;
        }

        return $this->version;
    }