Skip to content
Snippets Groups Projects
Commit 962fb661 authored by Jared Hancock's avatar Jared Hancock
Browse files

Use internal stdout and stderr objects for logging

Inside cli modules, use internal stdout and stderr objects rather than
writing directly to the PHP outputs. This will allow for significantly
easier regression testing integration.
parent f7c9ddbf
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,21 @@ class Option {
}
}
class OutputStream {
var $stream;
function OutputStream() {
call_user_func_array(array($this, '__construct'), func_get_args());
}
function __construct($stream) {
$this->stream = fopen($stream, 'w');
}
function write($what) {
fwrite($this->stream, $what);
}
}
class Module {
var $options = array();
......@@ -89,6 +104,9 @@ class Module {
var $usage = '$script [options] $args [arguments]';
var $autohelp = true;
var $stdout;
var $stderr;
var $_options;
var $_args;
......@@ -102,6 +120,8 @@ class Module {
'help'=>"Display this help message");
foreach ($this->options as &$opt)
$opt = new Option($opt);
$this->stdout = new OutputStream('php://output');
$this->stderr = new OutputStream('php://stderr');
}
function showHelp() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment