PHP code example of adrenalinkin / monolog-autowire-bundle
1. Go to this page and download the library: Download adrenalinkin/monolog-autowire-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adrenalinkin / monolog-autowire-bundle example snippets
declare(strict_types=1);
// app/AppKernel.php
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = [
// ...
new Linkin\Bundle\MonologAutowireBundle\LinkinMonologAutowireBundle(),
];
return $bundles;
}
// ...
}
declare(strict_types=1);
use Linkin\Bundle\MonologAutowireBundle\Logger\ChannelAcmeLogLogger;
use Linkin\Bundle\MonologAutowireBundle\Logger\ChannelDoctrineLogger;
use Psr\Log\LoggerInterface;
class AcmeLoggerAware
{
/**
* @var ChannelDoctrineLogger
*/
private $acmeLogLogger;
/**
* @var ChannelDoctrineLogger
*/
private $doctrineLogger;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @param ChannelAcmeLogLogger $acmeLogLogger
* @param ChannelDoctrineLogger $doctrineLogger
* @param LoggerInterface $logger
*/
public function __construct(
ChannelAcmeLogLogger $acmeLogLogger,
ChannelDoctrineLogger $doctrineLogger,
LoggerInterface $logger
) {
$this->acmeLogLogger = $acmeLogLogger;
$this->doctrineLogger = $doctrineLogger;
$this->logger = $logger;
}
public function doSome(): void
{
$this->acmeLogLogger->info('INFO into "acme_log" channel');
$this->doctrineLogger->info('INFO into "doctrine" channel');
$this->logger->info('INFO into Fallback or into NullLogger');
}
}
declare(strict_types=1);
use Linkin\Bundle\MonologAutowireBundle\Collection\LoggerCollection;
use Psr\Log\LoggerInterface;
class AcmeLoggerAware
{
/**
* @var LoggerInterface
*/
private $acmeLogLogger;
/**
* @var LoggerInterface
*/
private $doctrineLogger;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @param LoggerCollection $loggerCollection
*/
public function __construct(LoggerCollection $loggerCollection)
{
$this->acmeLogLogger = $loggerCollection->getLogger('acme_log');
$this->doctrineLogger = $loggerCollection->getLogger('doctrine');
$this->logger = $loggerCollection->getLogger();
}
public function doSome(): void
{
$this->acmeLogLogger->info('INFO into "acme_log" channel');
$this->doctrineLogger->info('INFO into "doctrine" channel');
$this->logger->info('INFO into Fallback or into NullLogger');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.