DataSift\Storyplayer\PlayerLib\Action_Logger::startAction PHP Method

startAction() public method

public startAction ( mixed $message, array | null $codeLine = null ) : Action_LogItem
$message mixed the message to write to the log
$codeLine array | null details about the line of code we are currently executing
return Action_LogItem the object that tracks this log entry
    public function startAction($message, $codeLine = null)
    {
        // do we have an open action?
        if (!$this->action || !$this->action->getIsOpen()) {
            $openItem = $this->action = new Action_LogItem($this->injectables, 1);
        } else {
            // this is a new nested item
            $openItem = $this->action->newNestedAction();
        }
        return $openItem->startAction($message, $codeLine);
    }

Usage Example

コード例 #1
0
ファイル: LoggerTest.php プロジェクト: datasift/storyplayer
 /**
  * @covers DataSift\Storyplayer\PlayerLib\Action_Logger::startAction
  * @covers DataSift\Storyplayer\PlayerLib\Action_Logger::getOpenAction
  */
 public function testGetOpenActionReturnsNullWhenNoActionOpen()
 {
     // ----------------------------------------------------------------
     // setup your test
     // the message we want to log
     $expectedMsg = "This is a test message";
     // our mock output facade
     $output = Mockery::mock("DataSift\\Storyplayer\\Output");
     $output->shouldReceive('logPhaseActivity')->once()->with($expectedMsg, null);
     // our mock DI container
     $i = new Injectables();
     $i->dataFormatter = new DataFormatter();
     $i->dataFormatter->setIsVerbose(true);
     $i->output = $output;
     // and, our test subject
     $obj = new Action_Logger($i);
     $log = $obj->startAction($expectedMsg);
     $log->endAction();
     // ----------------------------------------------------------------
     // perform the change
     $action = $obj->getOpenAction();
     // ----------------------------------------------------------------
     // test the results
     $this->assertNull($action);
     // all done
     Mockery::close();
 }
All Usage Examples Of DataSift\Storyplayer\PlayerLib\Action_Logger::startAction