Integrates the Monolog logging framework with Behat.
Add the dependency to composer.json,
"require": {
...
"swestcott/monolog-extension": "*"
}
And install/update your dependancies,
$ curl https://getcomposer.org/installer | php
$ php composer.phar install
# behat.yml
default:
extensions:
swestcott\MonologExtension\Extension:
handlers:
stdout:
type: stream
path: php:https://stdout
level: debug
Each context/subcontext is assigned it's own Monolog channel, named after context class name. It is set directly against the context.
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,
[2013-01-01 00:00:00] FeatureContext.INFO: Adding "1" and "2" [] []
Including context in messages
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,
[2013-01-01 00:00:00] FeatureContext.INFO: Adding values ["1", "2"] []
Copyright (c) 2013 Simon Westcott. See LICENSE for details.