Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to enable logger and define logger class #395

Merged
merged 1 commit into from
Dec 10, 2013

Conversation

pierredup
Copy link
Contributor

Fixes #118

Add the option to disable the logger and optionally specify the logger class.

The logger is enabled by default, but you can disable it per client by adding the enable_logger option:

fos_elastica:
    clients:
        default: { host: localhost, port: 9200, enable_logger : false}

You can also override the logger class by specifying a service id in the logger_class option:

fos_elastica:
    clients:
        default: { host: localhost, port: 9200, logger_class: my.logger.service.id }

This might not be the most elegant solution, but I'm open for ideas if somebody has a different implementation.

@todo: documentation

@merk
Copy link
Member

merk commented Nov 4, 2013

We dont need 2 configuration parameters here.

  1. Rename logger class to logger (it isnt a class in any case, but a service identifier)
  2. Allow nulls and set the default to fos_elastica.logger, which would let the configuration look like:

Different logger:

fos_elastica:
    clients:
        default:
            host: localhost
            port: 9200
            logger: my.logger.service.id

Disable logger:

fos_elastica:
    clients:
        default:
            host: localhost
            port: 9200
            logger: false

@merk
Copy link
Member

merk commented Nov 4, 2013

Null and true in the logger configuration should be considered to use the default logger service as well.

@jmikola
Copy link
Member

jmikola commented Nov 12, 2013

Since the setLogger() method call is being added in the DI extension class (it's no longer hard-coded in the service definitions), we can simply omit the setLogger() call if the logger option is null or false. Changing the method to support a null argument shouldn't really be necessary.

@merk
Copy link
Member

merk commented Nov 12, 2013

The thing is everything in the configuration treats null as true - but that can just be handled by the configuration class.

@pierredup
Copy link
Contributor Author

@merk I have made the requested changes

@merk
Copy link
Member

merk commented Dec 4, 2013

Thanks, final request could you please squash the commits?

@pierredup
Copy link
Contributor Author

I actually tried, but for some reason screwed things up a bit. Will try again

@pierredup
Copy link
Contributor Author

@merk squashed :)

if (false !== $logger) {
$clientDef->addMethodCall('setLogger', array(new Reference($logger)));
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra closing brace here, or is it for the foreach and just not indented properly?

@pierredup
Copy link
Contributor Author

I'm not sure where that extra bracket came from

merk added a commit that referenced this pull request Dec 10, 2013
Add option to enable logger and define logger class
@merk merk merged commit da44ee6 into FriendsOfSymfony:master Dec 10, 2013
@merk
Copy link
Member

merk commented Dec 10, 2013

Thanks!

@makasim
Copy link
Member

makasim commented Dec 10, 2013

It seems I would have an error if I dont have the logger option set (I am updating the bundle from previous 3.0 version). I have next error while running ./app/console -vvv:

 [ErrorException]         
  Undefined index: logger

Exception trace:
 () at /home/skadabr/Projects/Remixcv/vendor/friendsofsymfony/elastica-bundle/FOS/ElasticaBundle/DependencyInjection/Configuration.php:81
 UniversalErrorCatcher_Catcher->handleError() at /home/skadabr/Projects/Remixcv/vendor/friendsofsymfony/elastica-bundle/FOS/ElasticaBundle/DependencyInjection/Configuration.php:81
 FOS\ElasticaBundle\DependencyInjection\Configuration->FOS\ElasticaBundle\DependencyInjection\{closure}() at n/a:n/a

bastnic added a commit to bastnic/FOSElasticaBundle that referenced this pull request Mar 5, 2014
bastnic added a commit to bastnic/FOSElasticaBundle that referenced this pull request Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable logger
4 participants