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


PHP ClientBuilder::defaultLogger方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     global $argv;
     $this->colors = new Colors();
     if (file_exists('resume.lock') && $argv[1] != 'resume') {
         $this->resume();
     }
     if (isset($argv[1]) && $argv[1] == 'resume') {
         echo PHP_EOL . 'Resuming from previous state' . PHP_EOL;
         if (file_exists('resume.lock')) {
             $this->offset = (int) file_get_contents('resume.lock');
         } else {
             echo PHP_EOL . 'resume.lock file does not exist. Exiting...';
             die(PHP_EOL);
         }
     }
     if (strlen(DB_TABLE) == 0) {
         echo PHP_EOL . $this->colors->getColoredString("Database table is not defined. Please check the Config.php file.", 'red') . PHP_EOL;
         die;
     }
     try {
         $this->database = new medoo(['database_type' => 'mysql', 'database_name' => DB_NAME, 'server' => DB_HOST, 'username' => DB_USER, 'password' => DB_PASS, 'charset' => 'utf8', 'port' => DB_PORT]);
     } catch (Exception $e) {
         echo PHP_EOL . $this->colors->getColoredString("Error While Connection to mySQL Database,\nPlease check your Database connection settings in config.php", 'red') . PHP_EOL;
         die;
     }
     if (USE_DB_COLUMN == TRUE) {
         $this->idCol = DB_COL;
     }
     global $ES_HOST;
     $this->logger = \Elasticsearch\ClientBuilder::defaultLogger('mySQLtoes.log');
     $this->elasticSearch = \Elasticsearch\ClientBuilder::create()->setLogger($this->logger)->setHosts($ES_HOST)->build();
 }
开发者ID:hazaveh,项目名称:mySQLtoes,代码行数:33,代码来源:mySQLtoes.php

示例2: buildClient

 /**
  * Build and configure an Elasticsearch client.
  *
  * @param array $config
  * @return \Elasticsearch\Client
  */
 protected function buildClient(array $config)
 {
     $clientBuilder = ClientBuilder::create();
     // Configure hosts
     $clientBuilder->setHosts($config['hosts']);
     // Configure logging
     if (array_get($config, 'logging')) {
         $logObject = array_get($config, 'logObject');
         $logPath = array_get($config, 'logPath');
         $logLevel = array_get($config, 'logLevel');
         if ($logObject && $logObject instanceof LoggerInterface) {
             $clientBuilder->setLogger($logObject);
         } else {
             if ($logPath && $logLevel) {
                 $logObject = ClientBuilder::defaultLogger($logPath, $logLevel);
                 $clientBuilder->setLogger($logObject);
             }
         }
     }
     // Set additional client configuration
     foreach ($this->configMappings as $key => $method) {
         $value = array_get($config, $key);
         if ($value !== null) {
             call_user_func([$clientBuilder, $method], $value);
         }
     }
     // Build and return the client
     return $clientBuilder->build();
 }
开发者ID:cviebrock,项目名称:laravel-elasticsearch,代码行数:35,代码来源:Factory.php

示例3: createLoggerConfig

 /**
  * Create a new logger instance for the Elasticsearch client and modify the
  * config for the client builder accordingly.
  *
  * @param  array $config
  * @return array
  */
 protected function createLoggerConfig($config)
 {
     $logger = \Elasticsearch\ClientBuilder::defaultLogger($config['logPath'], $config['logLevel']);
     unset($config['logPath'], $config['logLevel']);
     $config['logger'] = $logger;
     return $config;
 }
开发者ID:elodex,项目名称:elodex,代码行数:14,代码来源:ElasticsearchClientManager.php

示例4: buildClient

 /**
  * Build and configure an Elasticsearch client.
  *
  * @param array $config
  * @return \Elasticsearch\Client
  */
 protected function buildClient(array $config)
 {
     $clientBuilder = ClientBuilder::create();
     // Configure hosts
     $clientBuilder->setHosts($config['hosts']);
     // Configure SSL
     if (isset($config['sslVerification']) && $config['sslVerification'] !== null) {
         $clientBuilder->setSSLVerification($config['sslVerification']);
     }
     // Configure logging
     if (isset($config['logging']) && $config['logging']) {
         if (isset($config['logObject']) && $config['logObject'] instanceof LoggerInterface) {
             $clientBuilder->setLogger($config['logObject']);
         } else {
             if (isset($config['logPath']) && isset($config['logLevel'])) {
                 $path = $config['logPath'];
                 $level = $config['logLevel'];
                 $logger = ClientBuilder::defaultLogger($path, $level);
                 $clientBuilder->setLogger($logger);
             }
         }
     }
     // Configure Sniff-on-Start
     if (isset($config['sniffOnStart']) && $config['sniffOnStart'] !== null) {
         $clientBuilder->setSniffOnStart($config['sniffOnStart']);
     }
     // Configure Retries
     if (isset($config['retries']) && $config['retries'] !== null) {
         $clientBuilder->setRetries($config['retries']);
     }
     // Configure HTTP Handler
     if (isset($config['httpHandler']) && $config['httpHandler'] !== null) {
         $clientBuilder->setHandler($config['httpHandler']);
     }
     // Configure Connection Pool
     if (isset($config['connectionPool']) && $config['connectionPool'] !== null) {
         $clientBuilder->setConnectionPool($config['connectionPool']);
     }
     // Configure Connection Selector
     if (isset($config['connectionSelector']) && $config['connectionSelector'] !== null) {
         $clientBuilder->setSelector($config['connectionSelector']);
     }
     // Configure Serializer
     if (isset($config['serializer']) && $config['serializer'] !== null) {
         $clientBuilder->setSerializer($config['serializer']);
     }
     // Configure Connection Factory
     if (isset($config['connectionFactory']) && $config['connectionFactory'] !== null) {
         $clientBuilder->setConnectionFactory($config['connectionFactory']);
     }
     // Configure Endpoint
     if (isset($config['endpoint']) && $config['endpoint'] !== null) {
         $clientBuilder->setEndpoint($config['endpoint']);
     }
     // Build and return the client
     return $clientBuilder->build();
 }
开发者ID:xian13,项目名称:laravel-elasticsearch-1,代码行数:63,代码来源:Factory.php

示例5: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('elasticsearch', function () {
         $connParams = [];
         $connParams['hosts'] = array('localhost:9200');
         $connParams['logPath'] = storage_path() . '/logs/elasticsearch-' . php_sapi_name() . '.log';
         // merge settings from app/config/elasticsearch.php
         $params = array_merge($connParams, $this->app['config']->get('elasticsearch'));
         $logger = ClientBuilder::defaultLogger($params['logPath']);
         return ClientBuilder::create()->setHosts($params['hosts'])->setLogger($logger)->build();
     });
     // Shortcut so developers don't need to add an Alias in app/config/app.php
     $this->app->booting(function () {
         $loader = AliasLoader::getInstance();
         $loader->alias('Es', 'Shift31\\LaravelElasticsearch\\Facades\\Es');
     });
 }
开发者ID:shift31,项目名称:laravel-elasticsearch,代码行数:22,代码来源:LaravelElasticsearchServiceProvider.php

示例6: buildClient

 /**
  * Build and configure an Elasticsearch client.
  *
  * @param array $config
  * @return \Elasticsearch\Client
  */
 protected function buildClient(array $config)
 {
     $clientBuilder = ClientBuilder::create();
     $clientBuilder->setHosts($config['hosts']);
     if ($config['sslVerification'] !== null) {
         $clientBuilder->setSSLVerification($config['sslVerification']);
     }
     if ($config['logging']) {
         $path = $config['logging']['path'];
         $level = $config['logging']['level'];
         $logger = ClientBuilder::defaultLogger($path, $level);
         $clientBuilder->setLogger($logger);
     }
     if ($config['sniffOnStart'] !== null) {
         $clientBuilder->setSniffOnStart($config['sniffOnStart']);
     }
     if ($config['retries'] !== null) {
         $clientBuilder->setRetries($config['retries']);
     }
     if ($config['httpHandler'] !== null) {
         $clientBuilder->setHandler($config['httpHandler']);
     }
     if ($config['connectionPool'] !== null) {
         $clientBuilder->setConnectionPool($config['connectionPool']);
     }
     if ($config['connectionSelector'] !== null) {
         $clientBuilder->setSelector($config['connectionSelector']);
     }
     if ($config['serializer'] !== null) {
         $clientBuilder->setSerializer($config['serializer']);
     }
     if ($config['connectionFactory'] !== null) {
         $clientBuilder->setConnectionFactory($config['connectionFactory']);
     }
     if ($config['endpoint'] !== null) {
         $clientBuilder->setEndpoint($config['endpoint']);
     }
     return $clientBuilder->build();
 }
开发者ID:phroggyy,项目名称:discover,代码行数:45,代码来源:Factory.php

示例7: function

<?php

/**
 * Created by PhpStorm.
 * User: guivarch
 * Date: 15/09/15
 * Time: 15:10
 */
use Elasticsearch\ClientBuilder;
use Silex\Application;
use Monolog\Logger;
$app['elasticsearch'] = function () {
    $params = array();
    $hosts = self::getConnexion();
    $logger = ClientBuilder::defaultLogger("../log/elastic.log");
    $client = ClientBuilder::create()->setHosts($hosts)->setLogger($logger)->build();
    return $client;
};
开发者ID:Thomthomars,项目名称:es-solution,代码行数:18,代码来源:elastic.php

示例8: registerLogger

 /**
  * Register Elasticsearch client logger.
  */
 protected function registerLogger()
 {
     $this->app->singleton('ductible.client.logger', function ($app) {
         return ClientBuilder::defaultLogger($app->make('config')->get('ductible.log'));
     });
 }
开发者ID:krisanalfa,项目名称:ductible,代码行数:9,代码来源:DuctibleServiceProvider.php

示例9: buildClient

 /**
  * Create an elastic search instance.
  *
  * @param array $config
  *
  * @return Client
  */
 private function buildClient(array $config)
 {
     $client = ClientBuilder::create()->setHosts($config['hosts']);
     if (isset($config['retries'])) {
         $client->setRetries($config['retries']);
     }
     if (isset($config['logging']) and $config['logging']['enabled'] == true) {
         $logger = ClientBuilder::defaultLogger($config['logging']['path'], $config['logging']['level']);
         $client->setLogger($logger);
     }
     return $client->build();
 }
开发者ID:sleimanx2,项目名称:plastic,代码行数:19,代码来源:Connection.php


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