當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Yii::getLogger方法代碼示例

本文整理匯總了PHP中Yii::getLogger方法的典型用法代碼示例。如果您正苦於以下問題:PHP Yii::getLogger方法的具體用法?PHP Yii::getLogger怎麽用?PHP Yii::getLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Yii的用法示例。


在下文中一共展示了Yii::getLogger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getLogger

 /**
  * @return Logger
  */
 public function getLogger()
 {
     if (!isset($this->_logger)) {
         $this->_logger = \Yii::getLogger();
     }
     return $this->_logger;
 }
開發者ID:phtamas,項目名稱:yii2-mailer,代碼行數:10,代碼來源:Component.php

示例2: assignInternalStaffAuth

 /**
  * Adds the current LDAP-authenticated user to the 'internal_staff_auth' permissions group.
  */
 public function assignInternalStaffAuth()
 {
     $logger = \Yii::getLogger();
     $logger->init();
     $logger->flushInterval = 1;
     $logger->traceLevel = 0;
     $this->setIsNewRecord(True);
     $this->item_name = "internal_staff_auth";
     $this->user_id = (string) strval($this->user_id);
     if (intval($this->user_id) > 0) {
         $this->created_at = time();
         $this->created_by = "system";
         $this->updated_by = "system";
         $this->save();
     }
     $msg = "gms: assignInternalStaffAuth() for UserId: " . $this->user_id;
     \Yii::trace($msg . " (YT)", __METHOD__);
     //Use the convenience method 'TRACE'
     $logger->log($msg . " (LG)", 4);
     if (!empty($this->getErrors())) {
         $errs = $this->getErrors();
         foreach ($errs as $err) {
             foreach ($err as $item) {
                 $msg = "gms: ERR in assignInternalStaffAuth() -- " . $item;
                 //\Yii::trace($msg . " (YT)", __METHOD__);    //Use the convenience method 'TRACE'
                 //$logger->log($msg . " (LG)", 4);
             }
         }
     }
     $logger->flush();
     return null;
 }
開發者ID:gregsanders,項目名稱:stories,代碼行數:35,代碼來源:authassignment.php

示例3: afterAction

 protected function afterAction($action)
 {
     $time = sprintf('%0.5f', Yii::getLogger()->getExecutionTime());
     $memory = round(memory_get_peak_usage() / (1024 * 1024), 2) . "MB";
     echo '<!-- Time: ' . $time . 'ms, memory: ' . $memory . '-->';
     parent::afterAction($action);
 }
開發者ID:lp19851119,項目名稱:114la,代碼行數:7,代碼來源:Controller.php

示例4: getDBLogs

 public static function getDBLogs()
 {
     $results = array();
     $n = 0;
     foreach (Yii::getLogger()->getLogs() as $row) {
         if ($row[1] == CLogger::LEVEL_PROFILE && strpos($row[2], 'system.db.CDbCommand') === 0) {
             //						echo CVarDumper::dumpAsString($row, 10, true);
             $message = $row[0];
             if (strncasecmp($message, 'begin:', 6) === 0) {
                 $row[0] = substr($message, 6);
                 $row[4] = $n;
                 $stack[] = $row;
                 $n++;
             } else {
                 if (strncasecmp($message, 'end:', 4) === 0) {
                     $token = substr($message, 4);
                     if (($last = array_pop($stack)) !== null && $last[0] === $token) {
                         $delta = $row[3] - $last[3];
                         $results[$last[4]] = array($token, $delta, count($stack));
                     } else {
                         throw new CException(Yii::t('app', 'Mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.', array('{token}' => $token)));
                     }
                 }
             }
         }
     }
     $now = microtime(true);
     while (null !== ($last = array_pop($stack))) {
         $results[$last[4]] = array($last[0], $now - $last[3], count($stack));
     }
     ksort($results);
     return array_map(array(__CLASS__, 'formatLog'), $results);
 }
開發者ID:alexskull,項目名稱:Ushi,代碼行數:33,代碼來源:QtzPanelHelper.php

示例5: run

 public function run()
 {
     $dbStat = Yii::app()->db->getStats();
     $memory = round(Yii::getLogger()->memoryUsage / 1024 / 1024, 3);
     $time = round(Yii::getLogger()->executionTime, 3);
     echo "<div class='stat' id='stat'>\n           <div style='float:left;padding-right:5px'> запросов: {$dbStat[0]} </div>\n           <div style='float:left;padding-right:5px'> время: {$dbStat[1]} </div>\n           <div style='float:left;padding-right:5px'> память: {$memory} </div>\n           <div style='float:left;padding-right:5px'> выполнение: {$time} </div>\n        </div>";
 }
開發者ID:RSol,項目名稱:yupe,代碼行數:7,代碼來源:YPerformanceStatistic.php

示例6: afterAction

 protected function afterAction($action)
 {
     $time = sprintf('%0.5f', Yii::getLogger()->getExecutionTime());
     $memory = round(memory_get_peak_usage() / (1024 * 1024), 2) . "MB";
     echo "Time: {$time}, memory: {$memory}";
     parent::afterAction($action);
 }
開發者ID:moohwaan,項目名稱:yii-application-cookbook-2nd-edition-code,代碼行數:7,代碼來源:DbController.php

示例7: register

 public function register()
 {
     if ($this->getIsNewRecord() == false) {
         throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
     }
     if ($this->module->enableConfirmation == false) {
         $this->confirmed_at = time();
     }
     if ($this->module->enableGeneratingPassword) {
         $this->password = Password::generate(8);
     }
     $this->trigger(self::USER_REGISTER_INIT);
     if ($this->save()) {
         $this->trigger(self::USER_REGISTER_DONE);
         if ($this->module->enableConfirmation) {
             $token = \Yii::createObject(['class' => Token::className(), 'type' => Token::TYPE_CONFIRMATION]);
             $token->link('user', $this);
             $this->mailer->sendConfirmationMessage($this, $token);
         } else {
             \Yii::$app->user->login($this);
         }
         if ($this->module->enableGeneratingPassword) {
             $this->mailer->sendWelcomeMessage($this);
         }
         \Yii::$app->session->setFlash('info', $this->getFlashMessage());
         \Yii::getLogger()->log('User has been registered', Logger::LEVEL_INFO);
         return true;
     }
     \Yii::getLogger()->log('An error occurred while registering user account', Logger::LEVEL_ERROR);
     return false;
 }
開發者ID:AnduZhang,項目名稱:nws,代碼行數:31,代碼來源:User.php

示例8: actionConfirm

 /**
  * Overrided Confirm action
  *
  * @param int $id
  * @param string $code
  * @return string
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionConfirm($id, $code)
 {
     $user = $this->finder->findUserById($id);
     //$mailer = \Yii::$container->get(dektriumMailer::className());
     $mailer = new \common\helpers\Mandrill($user->email, 'Welcome to Razzd!', 'welcome', $sender = null, ['user' => $user, 'mandrill_template_name' => 'welcome']);
     if ($user === null || $this->module->enableConfirmation == false) {
         throw new NotFoundHttpException();
     }
     /** @var Token $token */
     $token = $this->findToken($id, $code, Token::TYPE_CONFIRMATION);
     if ($token === null || $token->isExpired) {
         \Yii::$app->session->setFlash('danger', \Yii::t('user', 'The confirmation link is invalid or expired. Please try requesting a new one.'));
     } else {
         $token->delete();
         $user->confirmed_at = time();
         \Yii::$app->user->login($user);
         \Yii::getLogger()->log('User has been confirmed', Logger::LEVEL_INFO);
         if ($user->save(false)) {
             \Yii::$app->session->setFlash('success', \Yii::t('user', 'Thank you, registration is now complete.'));
             $mailer->sendMessage();
         } else {
             \Yii::$app->session->setFlash('danger', \Yii::t('user', 'Something went wrong and your account has not been confirmed.'));
         }
     }
     return $this->render('/message', ['title' => \Yii::t('user', 'Account confirmation'), 'module' => $this->module]);
 }
開發者ID:babagay,項目名稱:razzd,代碼行數:35,代碼來源:RegistrationController.php

示例9: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $resources = array(YiiDebug::t('Page Load Time') => sprintf('%0.3F s.', $this->getLoadTime()), YiiDebug::t('Elapsed Time') => sprintf('%0.3F s.', $this->getRequestLoadTime()), YiiDebug::t('Memory Usage') => number_format(Yii::getLogger()->getMemoryUsage() / 1024) . ' KB', YiiDebug::t('Memory Peak Usage') => number_format(memory_get_peak_usage() / 1024) . ' KB');
     if (function_exists('mb_strlen') && isset($_SESSION)) {
         $resources[YiiDebug::t('Session Size')] = sprintf('%0.3F KB', mb_strlen(serialize($_SESSION)) / 1024);
     }
     $this->render('resource_usage', array('resources' => $resources));
 }
開發者ID:nojdug,項目名稱:domain,代碼行數:11,代碼來源:YiiDebugToolbarPanelResourceUsage.php

示例10: log

 /**
  * Logs a message.
  * @param int $level The logging level.
  * @param string $message The message to be logged.
  * @param array $context The log context.
  * @throws InvalidParamException The specified logging level is unknown.
  */
 public function log($level, $message, array $context = [])
 {
     if (!isset(static::$levels[$level])) {
         $values = implode(', ', (new \ReflectionClass('\\Mustache_Logger'))->getConstants());
         throw new InvalidParamException("Invalid enumerable value \"{$level}\". Please make sure it is among ({$values}).");
     }
     \Yii::getLogger()->log($message, static::$levels[$level], __METHOD__);
 }
開發者ID:cedx,項目名稱:yii2-mustache,代碼行數:15,代碼來源:Logger.php

示例11: init

 /**
  * Initialize the command object.
  */
 public function init()
 {
     // Tell yii to flush the logs every message (instead of buffering for the default 10,000)
     // Without this, you cannot use the log to find out where the script has got to in it's current run.
     Yii::getLogger()->autoFlush = 1;
     Yii::getLogger()->autoDump = true;
     parent::init();
 }
開發者ID:peopleperhour,項目名稱:yii-ses-feedback,代碼行數:11,代碼來源:ASesFeedbackCommand.php

示例12: init

 public function init()
 {
     parent::init();
     $logger = Yii::getLogger();
     $logger->autoFlush = $this->autoFlush;
     $logger->detachEventHandler('onFlush', array($this, 'collectLogs'));
     $logger->attachEventHandler('onFlush', array($this, 'processLogs'));
 }
開發者ID:openeyes,項目名稱:openeyes,代碼行數:8,代碼來源:FlushableLogRouter.php

示例13: getQueryCount

 protected function getQueryCount()
 {
     $logger = Yii::getLogger();
     if ($logger === null) {
         $this->markTestSkipped('I have not a logger');
     }
     return $logger->getDbProfiling()[0];
 }
開發者ID:yiister,項目名稱:yii2-mappable-ar,代碼行數:8,代碼來源:MappableARTest.php

示例14: enableLogging

 /**
  * Les logs ne sont pas enregistrés lors des tests avec PHPUnit.
  * Cette méthode permet de les réactiver.
  * @see http://www.yiiframework.com/wiki/271/how-to-re-enable-logging-during-unit-testing/
  */
 public static function enableLogging()
 {
     // automatically send every new message to available log routes
     Yii::getLogger()->autoFlush = 1;
     // when sending a message to log routes, also notify them to dump the message
     // into the corresponding persistent storage (e.g. DB, email)
     Yii::getLogger()->autoDump = true;
 }
開發者ID:ChristopheBrun,項目名稱:hLib,代碼行數:13,代碼來源:TestHelper.php

示例15: testMiddleware

 public function testMiddleware()
 {
     \Yii::getLogger()->flush();
     $this->commandBus->addMiddleware(new TestMiddleware());
     $result = $this->commandBus->handle(new TestCommand());
     $this->assertEquals('test ok', $result);
     $this->assertNotFalse(array_search('middleware test 1 ok', \Yii::$app->getLog()->logger->messages[1]));
     $this->assertNotFalse(array_search('middleware test 2 ok', \Yii::$app->getLog()->logger->messages[2]));
 }
開發者ID:trntv,項目名稱:yii2-command-bus,代碼行數:9,代碼來源:CommandBusTest.php


注:本文中的Yii::getLogger方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。