Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Log to STDOUT Feature #5721

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
// system error reporting, sum of: 1 = log; 4 = show
$config['debug_level'] = 1;

// log driver: 'syslog' or 'file'.
// log driver: 'syslog', 'stdout' or 'file'.
$config['log_driver'] = 'file';

// date format for log entries
Expand Down
4 changes: 2 additions & 2 deletions installer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@
<?php

$select_log_driver = new html_select(array('name' => '_log_driver', 'id' => "cfglogdriver"));
$select_log_driver->add(array('file', 'syslog'), array('file', 'syslog'));
$select_log_driver->add(array('file', 'syslog', 'stdout'), array('file', 'syslog', 'stdout'));
echo $select_log_driver->show($RCI->getprop('log_driver', 'file'));

?>
<div>How to do logging? 'file' - write to files in the log directory, 'syslog' - use the syslog facility.</div>
<div>How to do logging? 'file' - write to files in the log directory, 'syslog' - use the syslog facility, 'stdout' writes to the process' STDOUT file descriptor.</div>
</dd>

<dt class="propname">log_dir</dt>
Expand Down
7 changes: 7 additions & 0 deletions program/lib/Roundcube/rcube.php
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,13 @@ public static function write_log($name, $line)
return syslog($prio, $line);
}

// write message with file name when configured to log to STDOUT
if ($log_driver == 'stdout') {
$stdout = "php://stdout";
$line = "$name: $line";
return file_put_contents($stdout, $line, FILE_APPEND) !== false;
}

// log_driver == 'file' is assumed here

$line = sprintf("[%s]: %s\n", $date, $line);
Expand Down