MonologExtension
Integrates the Monolog logging framework with Behat., (*1)
Installation
Add the dependency to composer.json,, (*2)
"require": {
...
"swestcott/monolog-extension": "*"
}
And install/update your dependancies,, (*3)
$ curl http://getcomposer.org/installer | php
$ php composer.phar install
Configuration
# behat.yml
default:
extensions:
swestcott\MonologExtension\Extension:
handlers:
stdout:
type: stream
path: php://stdout
level: debug
Usage
Each context/subcontext is assigned it's own Monolog channel, named after context class name. It is set directly against the context., (*4)
Example 1
class FeatureContext extends BehatContext
{
/**
* @When /^I add together "([^"]*)" and "([^"]*)"$/
*/
public function iAddTogether($value1, $value2)
{
$this->logger->info('Adding "' . $value1 . '" and "' . $value2 . '"');
$this->result = $value1 + $value2;
}
}
Output,, (*5)
[2013-01-01 00:00:00] FeatureContext.INFO: Adding "1" and "2" [] []
Example 2
Including context in messages, (*6)
class FeatureContext extends BehatContext
{
/**
* @When /^I add together "([^"]*)" and "([^"]*)"$/
*/
public function iAddTogether($value1, $value2)
{
$this->logger->info('Adding values', array($value1, $value2));
$this->result = $value1 + $value2;
}
}
Output,, (*7)
[2013-01-01 00:00:00] FeatureContext.INFO: Adding values ["1", "2"] []
Copyright
Copyright (c) 2013 Simon Westcott. See LICENSE for details., (*8)