You are here

public function ErrorLogs::execute in DRD Agent 8.3

Same name and namespace in other branches
  1. 4.0.x src/Agent/Action/ErrorLogs.php \Drupal\drd_agent\Agent\Action\ErrorLogs::execute()

Execute an action.

Return value

mixed The response of the action as an array which will be encrypted before returned to DRD.

Overrides Base::execute

File

src/Agent/Action/ErrorLogs.php, line 13

Class

ErrorLogs
Provides a 'ErrorLogs' code.

Namespace

Drupal\drd_agent\Agent\Action

Code

public function execute() {
  $args = $this
    ->getArguments();
  $max_length = $args['maxLength'] ?? 5000;
  $log_file = ini_get('error_log');
  if (!file_exists($log_file)) {
    return [];
  }
  $offset = max(-1, filesize($log_file) - $max_length);
  $log = file_get_contents($log_file, FILE_BINARY, NULL, $offset);
  $result['php error log'] = $log;
  return $result;
}