Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ public function getConfigTreeBuilder()
->scalarNode('id')->end()
->scalarNode('host')->end()
->scalarNode('port')->defaultValue(9200)->end()
->scalarNode('transport')->defaultValue('http')->end()
->scalarNode('user')->defaultNull()->end()
->scalarNode('password')->defaultNull()->end()
->end()
->validate()
->ifTrue(function ($v) {
Expand Down
22 changes: 18 additions & 4 deletions DependencyInjection/MonologExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,25 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
} else {
// elastica client new definition
$elasticaClient = new Definition('%monolog.elastica.client.class%');
$elasticaClientArguments = array(
'host' => $handler['elasticsearch']['host'],
'port' => $handler['elasticsearch']['port'],
'transport' => $handler['elasticsearch']['transport'],
);

if (isset($handler['elasticsearch']['user']) && isset($handler['elasticsearch']['password'])) {
$elasticaClientArguments = array_merge(
$elasticaClientArguments,
array(
'headers' => array(
'Authorization ' => 'Basic ' . base64_encode($handler['elasticsearch']['user'] . ':' . $handler['elasticsearch']['password'])
)
)
);
}

$elasticaClient->setArguments(array(
array(
'host' => $handler['elasticsearch']['host'],
'port' => $handler['elasticsearch']['port'],
),
$elasticaClientArguments
));

$clientId = uniqid('monolog.elastica.client.');
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/schema/monolog-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,8 @@
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="transport" type="xsd:string" />
<xsd:attribute name="user" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
</xsd:complexType>
</xsd:schema>