本文整理匯總了PHP中common_Logger::singleton方法的典型用法代碼示例。如果您正苦於以下問題:PHP common_Logger::singleton方法的具體用法?PHP common_Logger::singleton怎麽用?PHP common_Logger::singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common_Logger
的用法示例。
在下文中一共展示了common_Logger::singleton方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getLogger
/**
*
* @return \Psr\Log\LoggerInterface
*/
public function getLogger()
{
if (is_null($this->logger)) {
$this->logger = new \common_log_Logger2Psr(\common_Logger::singleton());
}
return $this->logger;
}
示例2: analyseLogPerformance
public function analyseLogPerformance()
{
common_Logger::singleton()->enable();
$start = microtime(true);
for ($i = 0; $i < self::RUNS; $i++) {
// nothing
}
$emptyTime = microtime(true) - $start;
echo "Idle run: " . $emptyTime . "<br />";
$start = microtime(true);
for ($i = 0; $i < self::RUNS; $i++) {
common_Logger::t('a trace test message');
}
$traceTime = microtime(true) - $start;
echo "Trace run: " . $traceTime . "<br />";
$start = microtime(true);
for ($i = 0; $i < self::RUNS; $i++) {
common_Logger::i('a info test message');
}
$infoTime = microtime(true) - $start;
echo "Info run: " . $infoTime . "<br />";
common_Logger::singleton()->restore();
common_Logger::singleton()->disable();
$start = microtime(true);
for ($i = 0; $i < self::RUNS; $i++) {
common_Logger::i('a disabled test message');
}
$disabledTime = microtime(true) - $start;
echo "Disabled run: " . $disabledTime . "<br />";
common_Logger::singleton()->restore();
$start = microtime(true);
sleep(1);
$testwait = microtime(true) - $start;
echo "Wait: " . $testwait . "<br />";
echo "ok";
}
示例3: __construct
public function __construct($message = null, $code = 0, Exception $previous = null)
{
parent::__construct($message, $code);
common_Logger::singleton()->handleException($this);
}
示例4: registerErrorhandler
/**
* register a custom Errorhandler
*/
protected function registerErrorhandler()
{
// register the logger as erorhandler
common_Logger::singleton()->register();
}
示例5: __construct
public function __construct($serviceKey, $message = '')
{
parent::__construct('Service "' . $serviceKey . '" not found' . (empty($message) ? '' : ': ' . $message));
$this->serviceKey = $serviceKey;
\common_Logger::singleton()->handleException($this);
}