Skip to content
Browse files

add additional syslogging

  • Loading branch information...
1 parent e13f4e0 commit 6138dc9e7afc57b89a8f0745e3ba1ba1a0f62a5c Kevin Olbrich committed
Showing with 17 additions and 4 deletions.
  1. +7 −0 lib/CucumberScenario.php
  2. +10 −4 lib/Cuke4Php.php
View
7 lib/CucumberScenario.php
@@ -66,6 +66,7 @@ function invokeBeforeHooks($aTags) {
if (array_key_exists('tags', $aBeforeHook)) {
if (count($aBeforeHook['tags']) == 0 || count(array_intersect($aTags, $aBeforeHook['tags'])) > 0) {
$oStep = CucumberSteps::getInstance($aBeforeHook['class'], $this->aGlobals);
+ syslog(LOG_DEBUG,"Invoking Before Hook \"{$aBeforeHook['method']}\"");
$oResult = $oStep->invoke($aBeforeHook['method']);
if ($oResult === false) {
return array('failure');
@@ -89,6 +90,7 @@ function invokeAfterHooks($aTags) {
if (array_key_exists('tags', $aAfterHook)) {
if (count($aAfterHook['tags']) == 0 || count(array_intersect($aTags, $aAfterHook['tags'])) > 0) {
$oStep = CucumberSteps::getInstance($aAfterHook['class'], $this->aGlobals);
+ syslog(LOG_DEBUG,"Invoking After Hook \"{$aAfterHook['method']}\"");
$oResult = $oStep->invoke($aAfterHook['method']);
if ($oResult === false) {
return array('failure');
@@ -132,14 +134,19 @@ function invoke($iStepId, $aArgs) {
}
try {
+ syslog(LOG_DEBUG,"Invoking Step \"{$aStep['method']}\"");
call_user_func_array(array($oStep, $aStep['method']),$aArgs);
} catch (PHPUnit_Framework_IncompleteTestError $e) {
+ syslog(LOG_DEBUG,"Step Pending");
return array('pending',$e->getMessage());
} catch (PHPUnit_Framework_SkippedTestError $e) {
+ syslog(LOG_DEBUG,"Step Pending");
return array('pending',$e->getMessage());
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
+ syslog(LOG_DEBUG,"Step Failed due to unmet expectation: " . $e->getMessage());
return array('fail', array('message' => $e->getMessage()));
} catch (Exception $e) {
+ syslog(LOG_DEBUG,"Step failed due to ". get_class($e) ." exception :" . $e->getMessage());
return array('fail', array('message' => $e->getMessage() . " " . $e->getFile() . ":" . $e->getLine(), 'exception' => get_class($e), 'backtrace' => $e->getTraceAsString()));
}
return array('success');
View
14 lib/Cuke4Php.php
@@ -26,6 +26,7 @@ class Cuke4Php {
);
function __construct($_sFeaturePath, $_iPort = 16816) {
+ openlog("cuke4php", 0, LOG_DAEMON);
if (is_file($_sFeaturePath)) {
$_sFeaturePath = dirname($_sFeaturePath);
}
@@ -119,11 +120,12 @@ function __destruct() {
}
function run() {
- print "Cuke4Php listening on port $this->iPort\n";
+ syslog(LOG_INFO,"Cuke4Php listening on port $this->iPort\n");
$this->oSocket = socket_create_listen($this->iPort);
$this->bRun = true;
while ($this->bRun && ($connection = socket_accept($this->oSocket))) {
socket_getpeername($connection, $raddr, $rport);
+ syslog(LOG_INFO,"Connection from $raddr");
try {
while ($this->bRun && ($input = socket_read($connection, 4096, PHP_NORMAL_READ))) {
$data = trim($input);
@@ -135,11 +137,13 @@ function run() {
}
}
} catch (Exception $e) {
- if (socket_last_error($connection) != 54) {
- throw $e;
- };
+ if (socket_last_error($connection) != 54) {
+ syslog(LOG_ERR,$e->getMessage());
+ throw $e;
+ };
}
socket_close($connection);
+ syslog(LOG_INFO,"Connection closed");
sleep(1);
}
}
@@ -189,6 +193,7 @@ function process($sInput) {
* run any before hooks for a scenario
*/
function beginScenario($aTags) {
+ syslog(LOG_DEBUG,"Begin Scenario");
$this->setScenario(CucumberScenario::getInstance($this->aWorld));
return $this->oScenario->invokeBeforeHooks($aTags);
}
@@ -222,6 +227,7 @@ function stepMatches($sStep) {
*/
function endScenario($aTags) {
$oResult = $this->oScenario->invokeAfterHooks($aTags);
+ syslog(LOG_DEBUG,"End Scenario");
$this->oScenario = null;
return $oResult;
}

0 comments on commit 6138dc9

Please sign in to comment.
Something went wrong with that request. Please try again.