I want to create my own handler for monolog using this tutorial.
Now as my handler required PDO connection like this
$logger->pushHandler(new LogHandler(new PDO("mysql:host=$host;dbname=$dbname", $user, $pass)));
$logger->addInfo('My logger is now ready');
Then this guy told me insert that connection as service
LIke this
doctrine.dbal.default.wrapped_connection:
factory_service: doctrine.dbal.default_connection
factory_method: getWrappedConnection
class: PDO
my.monologhandler.pdo:
class: sojeans\BackBundle\Monolog\Handler\PDOHandler
arguments:
- '@doctrine.dbal.default.wrapped_connection'
tags:
- { name: log_handler }
But i am getting circular reference error so other guy told to do this
there is a circular reference here: you need to create the doctrine.dbal.default_connection service to create the doctrine.dbal.default.wrapped_connection`` (as it is used a factory service) and this service uses the logger.
But I don't know how to do that.