Integrates Monolog with Behat
PHP
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src/swestcott/MonologExtension
tests/swestcott/MonologExtension
.gitignore
.travis.yml
LICENSE.mb
README.md
composer.json
phpunit.xml.dist

README.md

MonologExtension

Integrates the Monolog logging framework with Behat.

Installation

Add the dependency to composer.json,

"require": {
    ...
    "swestcott/monolog-extension": "*"
}

And install/update your dependancies,

$ 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.

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,

[2013-01-01 00:00:00] FeatureContext.INFO: Adding "1" and "2" [] []

Example 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

Copyright (c) 2013 Simon Westcott. See LICENSE for details.