diff options
author | Douglas Reith <douglas@reith.com.au> | 2017-06-19 09:47:42 +1000 |
---|---|---|
committer | Jordi Boggiano <j.boggiano@seld.be> | 2017-06-19 01:47:42 +0200 |
commit | 765d225554770c45ee01267151769bab40bab91c (patch) | |
tree | 2c07b12edfc6845b32c987836d424966e93814c6 | |
parent | deb0ea4ee79a389b3004b0ef43499def511bbe9d (diff) | |
download | monolog-765d225554770c45ee01267151769bab40bab91c.zip monolog-765d225554770c45ee01267151769bab40bab91c.tar.gz monolog-765d225554770c45ee01267151769bab40bab91c.tar.bz2 |
Support HeadlessChrome (#966)
* Support HeadlessChrome
-rw-r--r-- | src/Monolog/Handler/ChromePHPHandler.php | 2 | ||||
-rw-r--r-- | tests/Monolog/Handler/ChromePHPHandlerTest.php | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/Monolog/Handler/ChromePHPHandler.php b/src/Monolog/Handler/ChromePHPHandler.php index b00fa84..785cb0c 100644 --- a/src/Monolog/Handler/ChromePHPHandler.php +++ b/src/Monolog/Handler/ChromePHPHandler.php @@ -36,7 +36,7 @@ class ChromePHPHandler extends AbstractProcessingHandler /** * Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+) */ - const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}'; + const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}'; protected static $initialized = false; diff --git a/tests/Monolog/Handler/ChromePHPHandlerTest.php b/tests/Monolog/Handler/ChromePHPHandlerTest.php index ef3cd1c..0449f8b 100644 --- a/tests/Monolog/Handler/ChromePHPHandlerTest.php +++ b/tests/Monolog/Handler/ChromePHPHandlerTest.php @@ -25,8 +25,13 @@ class ChromePHPHandlerTest extends TestCase $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0'; } - public function testHeaders() + /** + * @dataProvider agentsProvider + */ + public function testHeaders($agent) { + $_SERVER['HTTP_USER_AGENT'] = $agent; + $handler = new TestChromePHPHandler(); $handler->setFormatter($this->getIdentityFormatter()); $handler->handle($this->getRecord(Logger::DEBUG)); @@ -47,6 +52,16 @@ class ChromePHPHandlerTest extends TestCase $this->assertEquals($expected, $handler->getHeaders()); } + public static function agentsProvider() + { + return array( + array('Monolog Test; Chrome/1.0'), + array('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'), + array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36'), + array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36'), + ); + } + public function testHeadersOverflow() { $handler = new TestChromePHPHandler(); |