本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}
示例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');
});
}
示例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();
}
示例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;
};
示例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'));
});
}
示例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();
}