PHP code example of bref / logger

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

    

bref / logger example snippets


$logger = new \Bref\Logger\StderrLogger();

$logger->debug('This is a debug message');
$logger->info('This is an info');
$logger->warning('This is a warning');
$logger->error('This is an error');

$logger->warning('Invalid login attempt for email {email}', [
    'email' => $email,
]);

try {
   // ...
} catch (\Exception $e) {
    $logger->error('Impossible to complete the action', [
        'exception' => $e,
    ]);
}

$logger = new \Bref\Logger\StderrLogger(\Psr\Log\LogLevel::DEBUG);

[ERROR] Impossible to complete the action
InvalidArgumentException: Impossible to complete the action in /var/task/index.php:12
Stack trace:
#0 /var/task/index.php(86): main()
...