Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

swestcott/MonologExtension

Repository files navigation

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.

About

Integrates Monolog with Behat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages