1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-20 16:16:37 +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

@@ -31,12 +31,12 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
*
* Example of formatted string:
*
* You can do [blue text]{color: blue} or [green background]{background-color: green; color: white}
* You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white}
*
*/
protected function getDefaultFormatter()
{
return new LineFormatter('[%channel%]{macro: autolabel} [%level_name%]{font-weight: bold} %message%');
return new LineFormatter('[[%channel%]]{macro: autolabel} [[%level_name%]]{font-weight: bold} %message%');
}
/**
@@ -111,7 +111,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
$args = array(self::quote('font-weight: normal'));
$format = '%c' . $formatted;
$self = 'Monolog\Handler\BrowserConsoleHandler';
$format = preg_replace_callback('/\[(.*?)\]\{(.*?)\}/', function($m) use(&$args, $self) {
$format = preg_replace_callback('/\[\[(.*?)\]\]\{([^}]*)\}/s', function($m) use(&$args, $self) {
$args[] = $self::quote($self::handleCustomStyles($m[2], $m[1]));
$args[] = $self::quote('font-weight: normal');
return '%c' . $m[1] . '%c';