Procházet zdrojové kódy

Some consmetic changes

Olivier Poitrey před 12 roky
rodič
revize
65caca2b78

+ 3 - 4
src/Monolog/Handler/BrowserConsoleHandler.php

@@ -21,9 +21,8 @@ use Monolog\Formatter\LineFormatter;
  */
 class BrowserConsoleHandler extends AbstractProcessingHandler
 {
-    static protected
-        $initialized = false,
-        $records = array();
+    static protected $initialized = false;
+    static protected $records = array();
 
     /**
      * {@inheritDoc}
@@ -104,7 +103,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
                 );
             }
         }
-        return "(function(c){if (console && console.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);";
+        return "(function(c){if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);";
     }
 
     static public function handleStyles($formatted)

+ 4 - 4
tests/Monolog/Handler/BrowserConsoleHandlerTest.php

@@ -32,7 +32,7 @@ class BrowserConsoleHandlerTest extends TestCase
         $handler->handle($this->getRecord(Logger::DEBUG, 'foo[bar]{color: red}'));
 
         $expected = <<<EOF
-(function(c){if (console && console.groupCollapsed) {
+(function(c){if (c && c.groupCollapsed) {
 c.log("%cfoo%cbar%c", "font-weight: normal", "color: red", "font-weight: normal");
 }})(console);
 EOF;
@@ -50,7 +50,7 @@ EOF;
         $handler->handle($this->getRecord(Logger::DEBUG, '[foo]{macro: autolabel}'));
 
         $expected = <<<EOF
-(function(c){if (console && console.groupCollapsed) {
+(function(c){if (c && c.groupCollapsed) {
 c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
 c.log("%c%cbar%c", "font-weight: normal", "background-color: green; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
 c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
@@ -68,7 +68,7 @@ EOF;
         $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
 
         $expected = <<<EOF
-(function(c){if (console && console.groupCollapsed) {
+(function(c){if (c && c.groupCollapsed) {
 c.groupCollapsed("%ctest", "font-weight: normal");
 c.log("%c%s", "font-weight: bold", "Context");
 c.log("%s: %o", "foo", "bar");
@@ -93,7 +93,7 @@ EOF;
         $handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
 
         $expected = <<<EOF
-(function(c){if (console && console.groupCollapsed) {
+(function(c){if (c && c.groupCollapsed) {
 c.log("%ctest1", "font-weight: normal");
 c.log("%ctest2", "font-weight: normal");
 c.log("%ctest3", "font-weight: normal");