Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhanlon committed Sep 14, 2015
0 parents commit f1d01ba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Drupal Watchdog stdout

Log [Drupal Watchdog][1] messages to `php://stdout` or `php://stderr` for better log handling with Docker.

[1]: https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/watchdog/7
5 changes: 5 additions & 0 deletions log_stdout.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name = log_stdout
description = Log watchdog messages to stdout
package = Logging
version = VERSION
core = 7.x
21 changes: 21 additions & 0 deletions log_stdout.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

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']->name;
$request_uri = $log_entry['request_uri'];
$referer_uri = $log_entry['referer'];
fwrite($output, t('@severity: @message; user: @user; uri: @request_uri; referer: @referer_uri', array(
'@severity' => $severity,
'@message' => strip_tags(t($log_entry['message'], $log_entry['variables'])),
'@user' => $user,
'@request_uri' => $request_uri,
'@referer_uri' => $referer_uri,
)));
fclose($output);
}

0 comments on commit f1d01ba

Please sign in to comment.