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


PHP Entity::getTime方法代码示例

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


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

示例1: postImpl

 /**
  * @param Entity $entity
  * @return int
  */
 protected function postImpl(Entity $entity)
 {
     /*
      * example ouputs:
      *   2012-02-26T01:26:20+0900        debug.test      {"hello":"world"}
      */
     $format = "%s\t%s\t%s\n";
     return $this->write(sprintf($format, date(\DateTime::ISO8601, $entity->getTime()), $entity->getTag(), json_encode($entity->getData())));
 }
开发者ID:cy-katsuhiro-miura,项目名称:fuelphp-with-fluentd,代码行数:13,代码来源:ConsoleLogger.php

示例2: postImpl

 protected function postImpl(Entity $entity)
 {
     $packed = json_encode($entity->getData());
     $data = $wbuffer = sprintf("%s\t%s\t%s", date(\DateTime::ISO8601, $entity->getTime()), $entity->getTag(), $packed . PHP_EOL);
     $length = strlen($data);
     $written = 0;
     $retry = 0;
     try {
         if (!flock($this->fp, LOCK_EX)) {
             throw new \Exception('could not obtain LOCK_EX');
         }
         fseek($this->fp, 0, SEEK_END);
         while ($written < $length) {
             $nwrite = fwrite($this->fp, $wbuffer);
             if ($nwrite === false) {
                 throw new \Exception("could not write message");
             } else {
                 if ($nwrite === "") {
                     throw new \Exception("connection aborted");
                 } else {
                     if ($nwrite === 0) {
                         if ($retry > self::MAX_WRITE_RETRY) {
                             throw new \Exception("failed fwrite retry: max retry count");
                         }
                         $retry++;
                     }
                 }
             }
             $written += $nwrite;
             $wbuffer = substr($wbuffer, $written);
         }
         flock($this->fp, LOCK_UN);
     } catch (\Exception $e) {
         $this->processError($this, $entity, $e->getMessage());
         return false;
     }
     return true;
 }
开发者ID:andgorrie,项目名称:fluent-logger-php,代码行数:38,代码来源:FileLogger.php

示例3: pack

 /**
  * pack entity as a json string.
  *
  * @param Entity $entity
  * @return string
  */
 public function pack(Entity $entity)
 {
     return json_encode(array($entity->getTag(), $entity->getTime(), $entity->getData()));
 }
开发者ID:cy-katsuhiro-miura,项目名称:fuelphp-with-fluentd,代码行数:10,代码来源:JsonPacker.php


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