swestcott/monolog-extension

This package is abandoned and no longer maintained. No replacement package was suggested.

Monolog extension for Behat

dev-master 2015-07-05 23:31 UTC

This package is not auto-updated.

Last update: 2020-03-06 15:46:05 UTC


README

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.