Navigation Menu

Skip to content

Commit

Permalink
Reset profiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Oct 5, 2017
1 parent d2e9350 commit 963dc49
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Logger.php
Expand Up @@ -45,6 +45,16 @@ public function countErrors()
return 0;
}

/**
* {@inheritdoc}
*/
public function clear()
{
if (($logger = $this->getDebugLogger()) && method_exists($logger, 'clear')) {
$logger->clear();
}
}

/**
* Returns a DebugLoggerInterface instance if one is registered with this logger.
*
Expand Down
9 changes: 9 additions & 0 deletions Processor/DebugProcessor.php
Expand Up @@ -55,4 +55,13 @@ public function countErrors()
{
return $this->errorCount;
}

/**
* {@inheritdoc}
*/
public function clear()
{
$this->records = array();
$this->errorCount = 0;
}
}
13 changes: 13 additions & 0 deletions Tests/LoggerTest.php
Expand Up @@ -128,4 +128,17 @@ public function testGetLogsWithDebugProcessor2()
$this->assertEquals('test', $record['message']);
$this->assertEquals(Logger::INFO, $record['priority']);
}

public function testClear()
{
$handler = new TestHandler();
$logger = new Logger('test', array($handler));
$logger->pushProcessor(new DebugProcessor());

$logger->addInfo('test');
$logger->clear();

$this->assertEmpty($logger->getLogs());
$this->assertSame(0, $logger->countErrors());
}
}

0 comments on commit 963dc49

Please sign in to comment.