You are here

function log_stdout_watchdog in log_stdout 7

@file Defines a log_stdout_watchdog functions.

File

./log_stdout.module, line 8
Defines a log_stdout_watchdog functions.

Code

function log_stdout_watchdog(array $log_entry) {
  if ($log_entry['severity'] < WATCHDOG_WARNING) {
    $output = fopen('php://stderr', 'w');
  }
  else {
    $output = fopen('php://stdout', 'w');
  }
  $severity = strtoupper(watchdog_severity_levels()[$log_entry['severity']]);
  $user = $log_entry['user']->uid ? $log_entry['user']->name : 'anonymous';
  $request_uri = $log_entry['request_uri'];
  $referer_uri = $log_entry['referer'];
  $variables = $log_entry['variables'] ? $log_entry['variables'] : array();
  fwrite($output, t('WATCHDOG: [@severity] [@type] @message | user: @user | uri: @request_uri | referer: @referer_uri', array(
    '@severity' => $severity,
    '@type' => $log_entry['type'],
    '@message' => strip_tags(t($log_entry['message'], $variables)),
    '@user' => $user,
    '@request_uri' => $request_uri,
    '@referer_uri' => $referer_uri,
  )));
  fclose($output);
}