1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-12 16:14:08 +02:00

Use more "unique" markers format for styling

This commit is contained in:
Olivier Poitrey
2014-01-31 00:36:40 -08:00
parent ca88c4d4f3
commit e521588acb
2 changed files with 24 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ class BrowserConsoleHandlerTest extends TestCase
$handler = new BrowserConsoleHandler();
$handler->setFormatter($this->getIdentityFormatter());
$handler->handle($this->getRecord(Logger::DEBUG, 'foo[bar]{color: red}'));
$handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
@@ -40,14 +40,31 @@ EOF;
$this->assertEquals($expected, BrowserConsoleHandler::generateScript());
}
public function testEscaping()
{
$handler = new BrowserConsoleHandler();
$handler->setFormatter($this->getIdentityFormatter());
$handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
c.log("%c[foo] %c\"bar\\n[baz]\"%c", "font-weight: normal", "color: red", "font-weight: normal");
}})(console);
EOF;
$this->assertEquals($expected, BrowserConsoleHandler::generateScript());
}
public function testAutolabel()
{
$handler = new BrowserConsoleHandler();
$handler->setFormatter($this->getIdentityFormatter());
$handler->handle($this->getRecord(Logger::DEBUG, '[foo]{macro: autolabel}'));
$handler->handle($this->getRecord(Logger::DEBUG, '[bar]{macro: autolabel}'));
$handler->handle($this->getRecord(Logger::DEBUG, '[foo]{macro: autolabel}'));
$handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
$handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}'));
$handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {