Logger
extends Extension
in package
Log suites/tests/steps using Monolog library.
Monolog should be installed additionally by Composer.
composer require monolog/monolog
Codeception's core/internal stuff is logged into tests/_output/codeception.log
.
Test suites' steps are logged into tests/_output/<test_full_name>-<rotation_date>.log
.
To enable this module add to your codeception.yml
:
extensions:
enabled: [Codeception\Extension\Logger]
Config
-
max_files
(default: 3) - how many log files to keep
Table of Contents
Properties
- $events : mixed
- $config : mixed
- $globalConfig : mixed
- $logger : Logger
- $logHandler : mixed
- $options : mixed
- $output : mixed
- $path : mixed
- $modules : mixed
Methods
- __construct() : mixed
- _initialize() : mixed
- You can do all preparations here. No need to override constructor.
- _reconfigure() : mixed
- Pass config variables that should be injected into global config.
- afterTest() : mixed
- beforeStep() : mixed
- beforeSuite() : mixed
- beforeTest() : mixed
- endTest() : mixed
- getCurrentModuleNames() : mixed
- getDataDir() : mixed
- getGlobalConfig() : mixed
- getLogDir() : mixed
- getLogger() : mixed
- getModule() : mixed
- getRootDir() : mixed
- getSubscribedEvents() : array<string, string|array{0: string, 1: int}|array<int, array{0: string, 1?: int}>>
- Returns an array of event names this subscriber wants to listen to.
- getTestsDir() : mixed
- hasModule() : mixed
- receiveModuleContainer() : mixed
- testError() : mixed
- testFail() : mixed
- testIncomplete() : mixed
- testSkipped() : mixed
- write() : mixed
- writeln() : mixed
Properties
$events
public
static mixed
$events
= [\Codeception\Events::SUITE_BEFORE => 'beforeSuite', \Codeception\Events::TEST_BEFORE => 'beforeTest', \Codeception\Events::TEST_AFTER => 'afterTest', \Codeception\Events::TEST_END => 'endTest', \Codeception\Events::STEP_BEFORE => 'beforeStep', \Codeception\Events::TEST_FAIL => 'testFail', \Codeception\Events::TEST_ERROR => 'testError', \Codeception\Events::TEST_INCOMPLETE => 'testIncomplete', \Codeception\Events::TEST_SKIPPED => 'testSkipped']
$config
protected
mixed
$config
= ['max_files' => 3]
$globalConfig
protected
mixed
$globalConfig
$logger
protected
static Logger
$logger
$logHandler
protected
mixed
$logHandler
$options
protected
mixed
$options
$output
protected
mixed
$output
$path
protected
mixed
$path
$modules
private
mixed
$modules
= []
Methods
__construct()
public
__construct(mixed $config, mixed $options) : mixed
Parameters
- $config : mixed
- $options : mixed
_initialize()
You can do all preparations here. No need to override constructor.
public
_initialize() : mixed
Also you can skip calling _reconfigure
if you don't need to.
_reconfigure()
Pass config variables that should be injected into global config.
public
_reconfigure([array<string|int, mixed> $config = [] ]) : mixed
Parameters
- $config : array<string|int, mixed> = []
afterTest()
public
afterTest(TestEvent $e) : mixed
Parameters
- $e : TestEvent
beforeStep()
public
beforeStep(StepEvent $e) : mixed
Parameters
- $e : StepEvent
beforeSuite()
public
beforeSuite(SuiteEvent $e) : mixed
Parameters
- $e : SuiteEvent
beforeTest()
public
beforeTest(TestEvent $e) : mixed
Parameters
- $e : TestEvent
endTest()
public
endTest(TestEvent $e) : mixed
Parameters
- $e : TestEvent
getCurrentModuleNames()
public
getCurrentModuleNames() : mixed
getDataDir()
public
getDataDir() : mixed
getGlobalConfig()
public
getGlobalConfig() : mixed
getLogDir()
public
getLogDir() : mixed
getLogger()
public
static getLogger() : mixed
getModule()
public
getModule(mixed $name) : mixed
Parameters
- $name : mixed
getRootDir()
public
getRootDir() : mixed
getSubscribedEvents()
Returns an array of event names this subscriber wants to listen to.
public
static getSubscribedEvents() : array<string, string|array{0: string, 1: int}|array<int, array{0: string, 1?: int}>>
The array keys are event names and the value can be:
- The method name to call (priority defaults to 0)
- An array composed of the method name to call and the priority
- An array of arrays composed of the method names to call and respective priorities, or 0 if unset
For instance:
- ['eventName' => 'methodName']
- ['eventName' => ['methodName', $priority]]
- ['eventName' => [['methodName1', $priority], ['methodName2']]]
The code must not depend on runtime state as it will only be called at compile time. All logic depending on runtime state must be put into the individual methods handling the events.
Return values
array<string, string|array{0: string, 1: int}|array<int, array{0: string, 1?: int}>>getTestsDir()
public
getTestsDir() : mixed
hasModule()
public
hasModule(mixed $name) : mixed
Parameters
- $name : mixed
receiveModuleContainer()
public
receiveModuleContainer(SuiteEvent $e) : mixed
Parameters
- $e : SuiteEvent
testError()
public
testError(FailEvent $e) : mixed
Parameters
- $e : FailEvent
testFail()
public
testFail(FailEvent $e) : mixed
Parameters
- $e : FailEvent
testIncomplete()
public
testIncomplete(FailEvent $e) : mixed
Parameters
- $e : FailEvent
testSkipped()
public
testSkipped(FailEvent $e) : mixed
Parameters
- $e : FailEvent
write()
protected
write(mixed $message) : mixed
Parameters
- $message : mixed
writeln()
protected
writeln(mixed $message) : mixed
Parameters
- $message : mixed