public function testMaxDepth() { // Clear stack; add some testing data LoggerNDC::clear(); LoggerNDC::push('1'); LoggerNDC::push('2'); LoggerNDC::push('3'); LoggerNDC::push('4'); LoggerNDC::push('5'); LoggerNDC::push('6'); self::assertSame('1 2 3 4 5 6', LoggerNDC::get()); // Edge case, should not change stack LoggerNDC::setMaxDepth(6); self::assertSame('1 2 3 4 5 6', LoggerNDC::get()); self::assertSame(6, LoggerNDC::getDepth()); LoggerNDC::setMaxDepth(3); self::assertSame('1 2 3', LoggerNDC::get()); self::assertSame(3, LoggerNDC::getDepth()); LoggerNDC::setMaxDepth(0); self::assertSame('', LoggerNDC::get()); self::assertSame(0, LoggerNDC::getDepth()); }
/** * This method returns the NDC for this event. It will return the * correct content even if the event was generated in a different * thread or even on a different machine. The {@link LoggerNDC::get()} method * should <b>never</b> be called directly. * @return string */ public function getNDC() { if ($this->ndcLookupRequired) { $this->ndcLookupRequired = false; $this->ndc = LoggerNDC::get(); } return $this->ndc; }
/** * This method returns the NDC for this event. It will return the * correct content even if the event was generated in a different * thread or even on a different machine. The {@link LoggerNDC::get()} method * should <b>never</b> be called directly. * @return string */ function getNDC() { if ($this->ndcLookupRequired) { $this->ndcLookupRequired = false; $this->ndc = implode(' ', LoggerNDC::get()); } return $this->ndc; }