PHP code example of kod3r / log
1. Go to this page and download the library: Download kod3r/log 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/ */
kod3r / log example snippets
php
// app/AppKernel.php
public function registerBundles()
{
return array(
...
new Kod3r\LogBundle\Kod3rLogBundle(),
);
}
php
use Symfony\Component\HttpFoundation\Request;
public function indexAction( Request $request ){
// Obtener el manejador de logs
$logger = $this->get( 'monolog.logger.backtrace' );
// Obtener información de contexto a traves del servicio definido
$context = $this->get('kod3r_log.logger_utils')->getContext($this, $request);
// Definir parámetros extras del contexto
$context = array(
'custom': 'value'
);
// Agregar el log y el contexto
$logger->warning( 'Este es un mensaje de WARNING!!!', $context );
}