当前位置: 首页>>代码示例>>PHP>>正文


PHP Logger::log方法代码示例

本文整理汇总了PHP中Monolog\Logger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::log方法的具体用法?PHP Logger::log怎么用?PHP Logger::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monolog\Logger的用法示例。


在下文中一共展示了Logger::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: log

 /**
  * Записывает сообщение в лог.
  * @param string $level уровень критичности сообщения
  * @param string $message сообщение, поддерживает плейсхолдеры в формате {placeholder}
  * @param array $placeholders список плейсхолдеров
  * @return self
  */
 protected function log($level, $message, array $placeholders = [])
 {
     if ($this->traitLogger) {
         $this->traitLogger->log($level, $message, $placeholders);
     }
     return $this;
 }
开发者ID:Umisoft,项目名称:umi-extension-monolog,代码行数:14,代码来源:TMonologAware.php

示例2: append

 /**
  * Appends the given message along with the additional information into the log.
  *
  * @param string $message The message to log
  * @param integer $severity One of the LOG_* constants
  * @param mixed $additionalData A variable containing more information about the event to be logged
  * @param string $packageKey Key of the package triggering the log (determined automatically if not specified)
  * @param string $className Name of the class triggering the log (determined automatically if not specified)
  * @param string $methodName Name of the method triggering the log (determined automatically if not specified)
  * @return void
  * @api
  */
 public function append($message, $severity = LOG_INFO, $additionalData = NULL, $packageKey = NULL, $className = NULL, $methodName = NULL)
 {
     switch ($severity) {
         case LOG_EMERG:
             $monologLevel = Logger::EMERGENCY;
             break;
         case LOG_ALERT:
             $monologLevel = Logger::ALERT;
             break;
         case LOG_CRIT:
             $monologLevel = Logger::CRITICAL;
             break;
         case LOG_ERR:
             $monologLevel = Logger::ERROR;
             break;
         case LOG_WARNING:
             $monologLevel = Logger::WARNING;
             break;
         case LOG_NOTICE:
             $monologLevel = Logger::NOTICE;
             break;
         case LOG_DEBUG:
             $monologLevel = Logger::DEBUG;
             break;
         default:
             $monologLevel = Logger::INFO;
             break;
     }
     $this->logger->log($monologLevel, $message, ['packageKey' => $packageKey, 'className' => $className, 'methodName' => $methodName, 'additionalData' => $additionalData]);
 }
开发者ID:kitsunet,项目名称:Flowpack.Monolog,代码行数:42,代码来源:FlowBackendFacade.php

示例3: testNotifyGetsPassedCorrectlyMappedSeverity

 /**
  * The three arguments below are provided by:
  * @dataProvider provideMappedSeverities
  *
  */
 public function testNotifyGetsPassedCorrectlyMappedSeverity($monologLevel, $expectedSeverity)
 {
     // Update the tested handler to always send messages rather than just errors.
     $this->monolog->popHandler($this->testedHandler);
     $this->testedHandler = new BugsnagHandler($this->mockBugsnag->reveal(), Logger::DEBUG);
     $this->monolog->pushHandler($this->testedHandler);
     $errorMessage = "Oh no!";
     $this->mockBugsnag->notifyError($expectedSeverity, Argument::any(), Argument::any(), $expectedSeverity)->shouldBeCalledTimes(1);
     $this->monolog->log($monologLevel, $errorMessage);
 }
开发者ID:koliesnik,项目名称:MonoSnag,代码行数:15,代码来源:BugsnagHandlerTest.php

示例4: getDueTasks

 /**
  * Get tasks that are due to run
  *
  * @access public
  * @return array A list of {@link Task} objects.
  */
 public function getDueTasks()
 {
     $this->logger->log(Logger::DEBUG, 'Checking tasks that are due to run. ' . count($this->tasks) . ' total tasks.');
     $t = [];
     foreach ($this->tasks as $task) {
         $this->logger->log(Logger::DEBUG, 'Checking on "' . $task->getName() . '" (' . $task->getCronString() . ')');
         if ($task->isDue()) {
             $t[] = $task;
             $this->logger->log(Logger::DEBUG, '"' . $task->getName() . '" IS set to run');
         } else {
             $this->logger->log(Logger::DEBUG, '"' . $task->getName() . '" is not set to run');
         }
     }
     return $t;
 }
开发者ID:shideon,项目名称:tasker,代码行数:21,代码来源:Tasker.php

示例5: write

 /**
  * 写入日志
  * @param $msg
  * @param $name
  * @param int $level
  * @param AbstractHandler $handler
  */
 public static function write($msg, $name, $level = Logger::INFO, AbstractHandler $handler = null)
 {
     $name .= '_' . $level;
     $name = $name . '_' . date('Y-m-d-H', Date::now());
     if (isset(self::$loggers[$name])) {
         $logger = self::$loggers[$name];
         if ($handler != null) {
             $logger->pushHandler($handler);
         }
     } else {
         $logger = new Logger($name);
         if ($handler == null) {
             $path = ConfigManager::get('log');
             $handler = new StreamHandler($path . DIRECTORY_SEPARATOR . $name . '.log', $level);
             $formatter = new LineFormatter(ConfigManager::get('log_formatter'), 'Y-m-d H:i:s');
             $handler->setFormatter($formatter);
         }
         $logger->pushHandler($handler);
         self::$loggers[$name] = $logger;
     }
     if (is_scalar($msg) === false) {
         $msg = json_encode($msg);
     }
     $logger->log($level, $msg);
 }
开发者ID:songsihan,项目名称:simple,代码行数:32,代码来源:LogUtil.php

示例6: extractDatasFromXML

 /**
  * Extract metadatas from XML
  * 
  * @param \DOMDocument $document wanted document
  * @return array 
  */
 private function extractDatasFromXML(\DOMDocument $document)
 {
     $datas = array();
     $xpath = new \DOMXPath($document);
     $xPathQuery = CssSelector::toXPath('description > *');
     $structure = $this->config->get('structure');
     foreach ($xpath->query($xPathQuery) as $node) {
         $nodeName = $node->nodeName;
         $value = $node->nodeValue;
         $meta = isset($structure[$nodeName]) ? $structure[$nodeName] : null;
         $isMulti = !isset($meta['multi']) ? false : !!$meta['multi'];
         if (!$meta) {
             $this->logger->log(sprintf('undefined meta name %s', $nodeName));
             continue;
         }
         if (!isset($datas[$nodeName])) {
             $datas[$nodeName] = array('values' => array(), 'meta_src' => $meta['src'], 'multi' => $isMulti);
         }
         if ($nodeName == 'Date' || $nodeName == 'DatePrisedeVue') {
             $value = str_replace('/', ':', $value);
         }
         $datas[$nodeName]['values'][] = $value;
     }
     return $datas;
 }
开发者ID:nlegoff,项目名称:Blender,代码行数:31,代码来源:WriteMetasFromXML.php

示例7: authenticate

 /**
  * Performs an authentication attempt
  *
  * @return \Zend\Authentication\Result
  * @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface If authentication cannot be performed
  */
 public function authenticate()
 {
     $result = null;
     foreach ($this->adapters as $adapter) {
         $result = $adapter->authenticate();
         if ($this->logger !== null) {
             foreach ($result->getMessages() as $message) {
                 $this->logger->log($result->getCode() > 0 ? Logger::INFO : Logger::ERROR, $message);
             }
         }
         if ($result->isValid()) {
             //Stop processing on first success result
             break;
         }
     }
     return $result;
 }
开发者ID:sunnyct,项目名称:silexcmf-zend-authentication,代码行数:23,代码来源:Chain.php

示例8: blockRequest

 /**
  * block and log the user request
  */
 private function blockRequest()
 {
     if ($this->logger instanceof Logger) {
         $this->logger->log(Logger::INFO, sprintf("blocked a requests flood for page %s%s from ip: %s with cookie %s", $this->getHttpHost(), $this->getRequestUri(), $this->getIpAddress(), $this->getCookie()));
         header('HTTP/1.0 403 Forbidden');
     }
     exit(sprintf('please wait %s seconds and refresh the page', $this->blockingPeriod));
 }
开发者ID:aporat,项目名称:evasive,代码行数:11,代码来源:Evasive.php

示例9: log

 /**
  * On dispatch event listener - called on any event
  *
  * @param Event $event
  * @param string $eventName
  * @return void
  */
 private function log($level, $message, $ev, array $context = [])
 {
     if ($this->logger) {
         $message = sprintf("QueueGet [1;36m%s@%s[0m %s", $ev->getRoutingKey(), $ev->getExchangeName(), $message);
         $context["command"] = AddonsEvent::QUEUE_GET_COMMAND;
         $this->logger->log($level, $message, $context);
     }
 }
开发者ID:gallna,项目名称:amqp-event,代码行数:15,代码来源:QueueGetCommand.php

示例10: flushBuffer

 /**
  * {@inheritdoc}
  */
 public function flushBuffer($force = false)
 {
     if (!empty($this->request_arguments) || $force) {
         foreach ($this->buffer as $log_entry) {
             $this->logger->log($log_entry['level'], $log_entry['message'], array_merge($this->env_arguments, $this->request_arguments, $log_entry['context']));
         }
         $this->buffer = [];
     }
 }
开发者ID:activecollab,项目名称:logger,代码行数:12,代码来源:Logger.php

示例11: primeExceptionHandler

function primeExceptionHandler(Exception $exc)
{
    $logger = new Logger('app_runtime');
    $logger->pushHandler(new RotatingFileHandler(Filesystem::getInstance()->getPath('log') . '/app.log'));
    $code = $exc->getCode();
    if ($code == 0) {
        $code = Logger::ALERT;
    }
    $logger->log($code, $exc->getMessage());
}
开发者ID:primephp,项目名称:framework,代码行数:10,代码来源:functions.php

示例12: run

 /**
  * Run task
  *
  * Note that the optional params are here because the lib expects this
  * functionality but if a developer were to extend the lib, these may
  * no longer be relevant. For more on this, see the comment that's inside
  * {@link Shideon\Tasker\AbstractCommand::getConfigOptions()}
  *
  * @access public
  * @param bool $async Run asynchronously
  * @param string $configFile Config file to send to command.
  * @param string $logFile Log file to send to command.
  * @param string $logLevel Log level to pass to command.
  */
 public function run($async, $configFile = null, $logFile = null, $logLevel = null)
 {
     $this->validate();
     $cmd = $this->buildRunCommand($async, $configFile, $logFile, $logLevel);
     $this->logger->log(Logger::INFO, "Running task '" . $this->getName() . "' in background: {$cmd}");
     // note that we use shell_exec instead of symfony's
     // Process because it's causing issues with
     // sub process having open file handle.
     shell_exec($cmd);
 }
开发者ID:shideon,项目名称:tasker,代码行数:24,代码来源:Task.php

示例13: log

 /**
  * @see \Monolog\Logger::log()
  *
  * @param string $level [debug,info,notice,warning,error,critical,alert,emergency]
  * @param string $message
  * @param array $context
  * @return bool
  */
 public static function log($level, $message, array $context = [])
 {
     if (self::$logger == null) {
         if (self::$strict) {
             $e = new Exception("Logger has not been set!");
             $e->setData(array("level" => $level, "message" => $message, "context" => $context));
             throw $e;
         } else {
             return false;
         }
     }
     return self::$logger->log($level, $message, $context);
 }
开发者ID:keboola,项目名称:juicer,代码行数:21,代码来源:Logger.php

示例14: log

 public function log($level = Logger::INFO, $message = '[no message]', $context = array(), $description = null, $tags = array(), $serialiseContext = false)
 {
     $this->initLogger();
     // collect pertinent information for log
     $this->callingClass = $this->callingMethod = null;
     $this->tags = $tags;
     $this->description = $description;
     $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     $this->callingClass = isset($backtrace[1]['class']) ? $backtrace[1]['class'] : null;
     $this->callingMethod = isset($backtrace[1]['function']) ? $backtrace[1]['function'] : null;
     // optionally serialise the context data
     if ($serialiseContext && !empty($context)) {
         $context = ['context-serialised' => serialize($context)];
     }
     try {
         $this->logger->log($level, $message, is_array($context) ? $context : [$context]);
     } catch (Exception $e) {
         // something went wrong - investigation will be conducted when it is seen that no new logs are created
     }
 }
开发者ID:gavincsch,项目名称:jsonlogger,代码行数:20,代码来源:Loggable.php

示例15: getPrimaryKeyValue

 /**
  * @param \stdClass $dataRow
  * @param string $type for logging
  * @param string $outerObjectHash
  * @return string
  */
 protected function getPrimaryKeyValue(\stdClass $dataRow, $type, $outerObjectHash = null)
 {
     // Try to find a "real" parent ID
     if (!empty($this->primaryKeys[$this->createSafeName($type)])) {
         $pk = $this->primaryKeys[$this->createSafeName($type)];
         $pKeyCols = explode(',', $pk);
         $pKeyCols = array_map('trim', $pKeyCols);
         $values = [];
         foreach ($pKeyCols as $pKeyCol) {
             if (empty($dataRow->{$pKeyCol})) {
                 $values[] = md5(serialize($dataRow) . $outerObjectHash);
                 $this->log->log("WARNING", "Primary key for type '{$type}' was set to '{$pk}', but its column '{$pKeyCol}' does not exist! Using hash to link child objects instead.", ['row' => $dataRow]);
             } else {
                 $values[] = $dataRow->{$pKeyCol};
             }
         }
         return $type . "_" . join(";", $values);
     } else {
         // Of no pkey is specified to get the real ID, use a hash of the row
         return $type . "_" . md5(serialize($dataRow) . $outerObjectHash);
     }
 }
开发者ID:jobrieniii,项目名称:php-jsonparser,代码行数:28,代码来源:Parser.php


注:本文中的Monolog\Logger::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。