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


PHP Daemon::log方法代码示例

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


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

示例1: onReady

 /**
  * Called when the worker is ready to go.
  * @return void
  */
 public function onReady()
 {
     $appInstance = $this;
     // a reference to this application instance for ExampleWebSocketRoute
     \PHPDaemon\Servers\WebSocket\Pool::getInstance()->addRoute('ExamplePubSub', function ($client) use($appInstance) {
         return new ExamplePubSubWebSocketRoute($client, $appInstance);
     });
     $this->sql = \PHPDaemon\Clients\MySQL\Pool::getInstance();
     $this->pubsub = new \PHPDaemon\PubSub\PubSub();
     $this->pubsub->addEvent('usersNum', \PHPDaemon\PubSub\PubSubEvent::init()->onActivation(function ($pubsub) use($appInstance) {
         \PHPDaemon\Core\Daemon::log('onActivation');
         if (isset($pubsub->event)) {
             \PHPDaemon\Core\Timer::setTimeout($pubsub->event, 0);
             return;
         }
         $pubsub->event = setTimeout(function ($timer) use($pubsub, $appInstance) {
             $appInstance->sql->getConnection(function ($sql) use($pubsub) {
                 if (!$sql->connected) {
                     return;
                 }
                 $sql->query('SELECT COUNT(*) `num` FROM `dle_users`', function ($sql, $success) use($pubsub) {
                     $pubsub->pub(sizeof($sql->resultRows) ? $sql->resultRows[0]['num'] : 'null');
                 });
             });
             $timer->timeout(5000000.0);
             // 5 seconds
         }, 0);
     })->onDeactivation(function ($pubsub) {
         if (isset($pubsub->event)) {
             \PHPDaemon\Core\Timer::cancelTimeout($pubsub->event);
         }
     }));
 }
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:37,代码来源:ExamplePubSub.php

示例2: bindSocket

 /**
  * Bind given socket
  * @param  string $uri Address to bind
  * @return boolean      Success
  */
 public function bindSocket($uri)
 {
     $u = \PHPDaemon\Config\Object::parseCfgUri($uri);
     $scheme = $u['scheme'];
     if ($scheme === 'unix') {
         $socket = new \PHPDaemon\BoundSocket\UNIX($u);
     } elseif ($scheme === 'udp') {
         $socket = new \PHPDaemon\BoundSocket\UDP($u);
         if (isset($this->config->port->value)) {
             $socket->setDefaultPort($this->config->port->value);
         }
     } elseif ($scheme === 'tcp') {
         $socket = new \PHPDaemon\BoundSocket\TCP($u);
         if (isset($this->config->port->value)) {
             $socket->setDefaultPort($this->config->port->value);
         }
     } else {
         Daemon::log(get_class($this) . ': enable to bind \'' . $uri . '\': scheme \'' . $scheme . '\' is not supported');
         return false;
     }
     $socket->attachTo($this);
     if ($socket->bindSocket()) {
         if ($this->enabled) {
             $socket->enable();
         }
         return true;
     }
     return false;
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:34,代码来源:Server.php

示例3: run

 public function run()
 {
     $this->proxy = $this->orm->appInstance->proxy;
     $this->params = $this['args'][0];
     try {
         $this->orm->appInstance->httpclient->post('https://account.fineproxy.org/proxy/download/http_auth/txt/', ['log' => $this->params['username'], 'pass' => $this->params['password'], 'logsub' => 'Войти'], function ($conn) {
             $proxies = [];
             foreach (explode("\n", $conn->body) as $addr) {
                 $addr = trim($addr);
                 if (!preg_match('~^\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+$~', $addr)) {
                     continue;
                 }
                 $proxies[] = ['type' => 'http', 'addr' => $addr, 'auth' => ['username' => $this->params['username'], 'password' => $this->params['password']]];
             }
             $source = 'Fineproxy-' . $this->params['username'];
             $itime = time();
             $j = (new ComplexJob(function ($j) use($source, $itime) {
                 $this->sendResult(true);
                 $this->proxy->removeProxyServer(['source' => $source, 'itime' => ['$lt' => $itime]]);
                 Daemon::log('complete');
             }))->maxConcurrency(5)->more(function () use(&$proxies, $source, $itime) {
                 foreach ($proxies as $k => $proxy) {
                     (yield 'proxy_' . $k => function ($jobname, $j) use($proxy, $itime) {
                         $this->proxy->newProxyServer($proxy)->setOnInsertMode(false)->attr(['itime' => $itime])->save(function ($o) use($jobname, $j) {
                             $j->setResult($jobname, $o->lastError());
                         });
                     });
                 }
             });
             $j();
         });
     } catch (Exception $e) {
         $this->sendResult(false);
     }
 }
开发者ID:kakserpom,项目名称:WakePHP,代码行数:35,代码来源:FetchFineproxy.php

示例4: onBound

 /**
  * Called when socket is bound
  * @return boolean Success
  */
 protected function onBound()
 {
     touch($this->path);
     chmod($this->path, 0770);
     if ($this->group === null && !empty($this->uri['pass'])) {
         $this->group = $this->uri['pass'];
     }
     if ($this->group === null && isset(Daemon::$config->group->value)) {
         $this->group = Daemon::$config->group->value;
     }
     if ($this->group !== null) {
         if (!@chgrp($this->path, $this->group)) {
             unlink($this->path);
             Daemon::log('Couldn\'t change group of the socket \'' . $this->path . '\' to \'' . $this->group . '\'.');
             return false;
         }
     }
     if ($this->user === null && !empty($this->uri['user'])) {
         $this->user = $this->uri['user'];
     }
     if ($this->user === null && isset(Daemon::$config->user->value)) {
         $this->user = Daemon::$config->user->value;
     }
     if ($this->user !== null) {
         if (!@chown($this->path, $this->user)) {
             unlink($this->path);
             Daemon::log('Couldn\'t change owner of the socket \'' . $this->path . '\' to \'' . $this->user . '\'.');
             return false;
         }
     }
     return true;
 }
开发者ID:shamahan,项目名称:phpdaemon,代码行数:36,代码来源:UNIX.php

示例5: onReady

 /**
  * @TODO DESCR
  * @return void
  */
 public function onReady()
 {
     if ($this->user === null) {
         $this->connected = true;
     }
     if ($this->connected) {
         parent::onReady();
         return;
     }
     $this->dbname = $this->path;
     $this->pool->getNonce(['dbname' => $this->dbname], function ($result) {
         if (isset($result['$err'])) {
             Daemon::log('MongoClient: getNonce() error with ' . $this->url . ': ' . $result['$err']);
             $this->finish();
         }
         $this->pool->auth(['user' => $this->user, 'password' => $this->password, 'nonce' => $result['nonce'], 'dbname' => $this->dbname], function ($result) {
             if (!isset($result['ok']) || !$result['ok']) {
                 Daemon::log('MongoClient: authentication error with ' . $this->url . ': ' . $result['errmsg']);
                 $this->finish();
                 return;
             }
             $this->connected = true;
             $this->onReady();
         }, $this);
     }, $this);
 }
开发者ID:Mrhjx2,项目名称:phpdaemon,代码行数:30,代码来源:Connection.php

示例6: onFrame

 /**
  * Called when new frame received.
  * @param string  Frame's contents.
  * @param integer Frame's type.
  * @return void
  */
 public function onFrame($data, $type)
 {
     if ($data === 'ping') {
         $this->client->sendFrame('pong', 'STRING', function ($client) {
             // optional. called when the frame is transmitted to the client
             \PHPDaemon\Core\Daemon::log('ExampleWebSocket: \'pong\' received by client.');
         });
     }
 }
开发者ID:shamahan,项目名称:phpdaemon,代码行数:15,代码来源:ExampleWebSocket.php

示例7: getObject

 public function getObject($type, $cond = null, $objOrCb = null)
 {
     $class = ClassFinder::find($type, $this->name, $this->ns);
     if (!class_exists($class)) {
         Daemon::log(get_class($this) . ': undefined class: ' . $class);
         return false;
     }
     return new $class($cond, $objOrCb, $this);
 }
开发者ID:kakserpom,项目名称:WakePHP,代码行数:9,代码来源:Generic.php

示例8: init

 public function init()
 {
     if ($this->config->enable->value) {
         Daemon::log(__CLASS__ . ' up.');
         $this->db = \PHPDaemon\Clients\Mongo\Pool::getInstance();
         $this->tags = array();
         $this->minMsgInterval = 1;
     }
 }
开发者ID:dreamsxin,项目名称:phpdaemon-muchat,代码行数:9,代码来源:Chat.php

示例9: onReady

 /**
  * Called when the worker is ready to go
  *
  * @return void
  */
 public function onReady()
 {
     // Adding listener
     // ComplexJob - STATE_WAITING
     $job = new \PHPDaemon\Core\ComplexJob(function ($job) {
         // ComplexJob - STATE_DONE
         /*array (
             'bar' =>
             array (
                   'job' => 'bar',
                   'success' => false,
                   'line' => 63,
             ),
             'foo' =>
             array (
                   'job' => 'foo',
                   'success' => true,
                   'line' => 84,
                   'arg' =>
                   array (
                     'param' => 'value',
                   ),
             ),
             'baz' =>
             array (
                   'job' => 'baz',
                   'success' => false,
                   'line' => 94,
             ),
           )*/
         \PHPDaemon\Core\Daemon::log($job->results);
     });
     // Adding listener
     // ComplexJob - STATE_WAITING
     $job->addListener(function ($job) {
         // ComplexJob - STATE_DONE
     });
     // Adding async job foo
     $job('foo', $this->foo(['param' => 'value']));
     // Adding with 1 sec delay
     \PHPDaemon\Core\Timer::add(function ($event) use($job) {
         // Adding async job bar
         $job('bar', function ($jobname, $job) {
             \PHPDaemon\Core\Timer::add(function ($event) use($jobname, $job) {
                 // Job done
                 $job->setResult($jobname, ['job' => 'bar', 'success' => false, 'line' => __LINE__]);
                 $event->finish();
             }, 1000.0 * 50);
         });
         // Adding async job baz. Equal $job('baz', $this->baz());
         $job->addJob('baz', $this->baz());
         // Run jobs. All listeners will be called when the jobs done
         // ComplexJob - STATE_RUNNING
         $job();
         $event->finish();
     }, 1000000.0 * 1);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:62,代码来源:ExampleComplexJob.php

示例10: __get

 /**
  * @param string $name
  * @return bool
  */
 public function __get($name)
 {
     $class = '\\WakePHP\\Components\\' . $name;
     if (!class_exists($class)) {
         Daemon::log(get_class($this) . ': undefined class: ' . $class);
         return false;
     }
     return $this->{$name} = new $class($this->req);
 }
开发者ID:kakserpom,项目名称:WakePHP,代码行数:13,代码来源:Components.php

示例11: onReady

 /**
  * Called when the worker is ready to go.
  * @return void
  */
 public function onReady()
 {
     $_ws = \PHPDaemon\Servers\WebSocket\Pool::getInstance();
     $_ws->addRoute('/sockjs', function ($client) {
         Daemon::log('call route at WebSocket Server');
         //Daemon::log($client);
         return new \SockJsAppRoute($client, $this);
     });
     $this->log('onReady at SockJsApp');
 }
开发者ID:aleksraiden,项目名称:phpdaemon-sockjs-example,代码行数:14,代码来源:SockJsApp.php

示例12: addRoute

 /**
  * Adds a route if it doesn't exist already.
  * @param  string   $path Route name.
  * @param  callable $cb   Route's callback.
  * @callback $cb ( )
  * @return boolean        Success.
  */
 public function addRoute($path, $cb)
 {
     $routeName = ltrim($path, '/');
     if (isset($this->routes[$routeName])) {
         Daemon::log(__METHOD__ . ': Route \'' . $path . '\' is already defined.');
         return false;
     }
     $this->routes[$routeName] = $cb;
     return true;
 }
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:17,代码来源:Pool.php

示例13: proxy

 /**
  * Returns a proxy callback function with logging for debugging purposes
  * @param  callable $cb   Callback
  * @param  mixed    $name Data
  * @return callable
  */
 public static function proxy($cb, $name = null)
 {
     static $i = 0;
     $n = ++$i;
     Daemon::log('Debug::proxy #' . $n . ': SPAWNED (' . json_encode($name) . ')');
     return function () use($cb, $name, $n) {
         Daemon::log('Debug::proxy #' . $n . ': CALLED (' . json_encode($name) . ')');
         call_user_func_array($cb, func_get_args());
     };
 }
开发者ID:zenus,项目名称:phpinx,代码行数:16,代码来源:Debug.php

示例14: onHandshake

 public function onHandshake()
 {
     $this->defineLocalMethods(['serverTest' => function () {
         $this->callRemote('clientTest', 'foobar', function () {
             Daemon::log('callback called');
         });
     }]);
     $this->onFrame('{"method":"methods","arguments":[{"clientTest":{}}],"callbacks":{"1":[0,"clientTest"]},"links":[]} ', 'STRING');
     parent::onHandshake();
 }
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:10,代码来源:ExampleDNode.php

示例15: onFrame

 /**
  * Called when new frame received.
  * @param string  Frame's contents.
  * @param integer Frame's type.
  * @return void
  */
 public function onFrame($data, $type)
 {
     D($data);
     Daemon::log('SockJsAppRoute');
     Daemon::log($data);
     if ($data === 'ping') {
         $this->client->sendFrame('pong');
     } else {
         $this->client->sendFrame($data);
     }
 }
开发者ID:aleksraiden,项目名称:phpdaemon-sockjs-example,代码行数:17,代码来源:SockJsAppRoute.php


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