PHP code example of juanchosl / logger

1. Go to this page and download the library: Download juanchosl/logger 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/ */

    

juanchosl / logger example snippets


$composer = new TextComposer;

$repository = new FileRepository(PATH . DIRECTORY_SEPARATOR . 'error.log');
$repository->setComposer($composer);

$logger = new JuanchoSL\Logger\Logger($repository);
$logger->error("This is a message error");

use JuanchoSL\Logger\Debugger;

$debugger = Debugger::init();
$debugger->setLogger('errors', $logger);

//.... your code ...

Debugger::get('errors')->error("This is a message error");

use JuanchoSL\Logger\Debugger;

$debugger = Debugger::init()
    ->setLogger('errors', $logger)
    ->setLogger('database', new Logger((new ModelRepository())->setComposer(new ObjectComposer)));

//.... your code ...

Debugger::get('errors')?->error("This is a message error");
Debugger::get('database')?->debug($sql);

use JuanchoSL\Logger\Debugger;

$debugger = Debugger::init()->setLogger('errors', $logger)->initFailuresHandler('errors', E_ALL^E_USER_NOTICE);

use JuanchoSL\Logger\Debugger;
use JuanchoSL\Orm\Engine\Drivers\Mysqli;

$debugger = Debugger::init()
    ->setLogger('errors', $logger)
    ->setLogger('database', new Logger((new ModelRepository())->setComposer(new ObjectComposer)))
    ->initFailuresHandler('errors', E_ALL^E_USER_NOTICE);

$database = new Mysqli($credentials);
$database->setLogger($debugger->getLogger('database'));