Skip to content

Commit

Permalink
changing Shell to use ConsoleLog
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed May 11, 2012
1 parent d107277 commit bb090c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Cake/Console/Shell.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -165,9 +165,19 @@ public function __construct($stdout = null, $stderr = null, $stdin = null) {
if ($this->stdout == null) { if ($this->stdout == null) {
$this->stdout = new ConsoleOutput('php://stdout'); $this->stdout = new ConsoleOutput('php://stdout');
} }
CakeLog::config('stdout', array(
'engine' => 'ConsoleLog',
'types' => array('notice', 'info'),
'stream' => $this->stdout,
));
if ($this->stderr == null) { if ($this->stderr == null) {
$this->stderr = new ConsoleOutput('php://stderr'); $this->stderr = new ConsoleOutput('php://stderr');
} }
CakeLog::config('stderr', array(
'engine' => 'ConsoleLog',
'types' => array('error', 'warning'),
'stream' => $this->stderr,
));
if ($this->stdin == null) { if ($this->stdin == null) {
$this->stdin = new ConsoleInput('php://stdin'); $this->stdin = new ConsoleInput('php://stdin');
} }
Expand Down
5 changes: 5 additions & 0 deletions lib/Cake/Test/Case/BasicsTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -596,9 +596,14 @@ public function testTranslateDomainCategoryPlural() {
public function testLogError() { public function testLogError() {
@unlink(LOGS . 'error.log'); @unlink(LOGS . 'error.log');


// disable stderr output for this test
CakeLog::disable('stderr');

LogError('Testing LogError() basic function'); LogError('Testing LogError() basic function');
LogError("Testing with\nmulti-line\nstring"); LogError("Testing with\nmulti-line\nstring");


CakeLog::enable('stderr');

$result = file_get_contents(LOGS . 'error.log'); $result = file_get_contents(LOGS . 'error.log');
$this->assertRegExp('/Error: Testing LogError\(\) basic function/', $result); $this->assertRegExp('/Error: Testing LogError\(\) basic function/', $result);
$this->assertNotRegExp("/Error: Testing with\nmulti-line\nstring/", $result); $this->assertNotRegExp("/Error: Testing with\nmulti-line\nstring/", $result);
Expand Down

0 comments on commit bb090c5

Please sign in to comment.