Skip to content
Extraits de code Groupes Projets
Valider d6533762 rédigé par mattab's avatar mattab
Parcourir les fichiers

Refs #4133 Fixing Logger and tests

parent bc1db791
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -109,6 +109,7 @@ class Config
}
$this->init();
if (isset($this->configGlobal['database_tests'])
|| isset($this->configLocal['database_tests'])
) {
......@@ -223,7 +224,6 @@ class Config
*/
public function init()
{
$this->clear();
$this->initialized = true;
$reportError = !empty($GLOBALS['PIWIK_TRACKER_MODE']);
......
......@@ -133,7 +133,7 @@ class Log
*
* @var string
*/
private $logMessageFormat = "[%tag%%datetime%] %message%";
private $logMessageFormat = "%tag%[%datetime%] %message%";
/**
* If we're logging to a file, this is the path to the file to log to.
......@@ -236,7 +236,6 @@ class Log
*/
public function formatMessage($level, $tag, $datetime, $message)
{
$tag = $tag ? $tag . ':' : '';
return str_replace(
array("%tag%", "%message%", "%datetime%", "%level%"),
array($tag, $message, $datetime, $this->getStringLevel($level)),
......@@ -332,7 +331,10 @@ class Log
}
if (is_string($message)) {
$message = '[' . $currentRequestKey . '] ' . $message;
if(!defined('PIWIK_TEST_MODE')
|| !PIWIK_TEST_MODE) {
$message = '[' . $currentRequestKey . '] ' . $message;
}
$message = $this->formatMessage($level, $tag, $datetime, $message);
if(!Common::isPhpCliMode()) {
......
......@@ -187,6 +187,7 @@ dummy backtrace'
public function testLogMessagesIgnoredWhenNotWithinLevel($backend)
{
Config::getInstance()->log['log_writers'] = array($backend);
Config::getInstance()->log['log_level'] = 'ERROR';
ob_start();
Log::info(self::TESTMESSAGE);
......@@ -203,13 +204,14 @@ dummy backtrace'
}
if ($backend == 'screen') {
if ($formatMessage) {
if ($formatMessage
&& !Common::isPhpCliMode()) {
$expectedMessage = '<pre>' . $expectedMessage . '</pre>';
}
$this->screenOutput = $this->removePathsFromBacktrace($this->screenOutput);
$this->assertEquals($expectedMessage . "\n", $this->screenOutput);
$this->assertEquals($expectedMessage . "\n", $this->screenOutput, "unexpected output: ".$this->screenOutput);
} else if ($backend == 'file') {
$this->assertTrue(file_exists(self::getLogFileLocation()));
......@@ -237,7 +239,7 @@ dummy backtrace'
private function checkNoMessagesLogged($backend)
{
if ($backend == 'screen') {
$this->assertEmpty($this->screenOutput);
$this->assertEmpty($this->screenOutput, "Output not empty: ".$this->screenOutput);
} else if ($backend == 'file') {
$this->assertFalse(file_exists(self::getLogFileLocation()));
} else if ($backend == 'database') {
......
......@@ -31,7 +31,7 @@
</ul>
</p>
<p>If you are new to the wonderful world of testing, <a href='README.txt'>see the README</a> for an introduction.</p>
<p>If you are new to the wonderful world of testing, <a href='https://github.com/piwik/piwik/blob/master/tests/README.md'>see the README</a> for an introduction.</p>
<img src='resources/disturbing-image.jpg' alt='I find your lack of tests disturbing'>
<br/><i><a href='http://www.flickr.com/photos/sebastian_bergmann/2282734669/'>Photo source & license</a></i>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter