PHP code example of mattferris / logging

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

    

mattferris / logging example snippets


use MattFerris\Logging\Logger;
use MattFerris\Logging\Handlers\FileHandler;

$logger = new Logger([
    ['handler' => new FileHandler('log.txt')]
]);

$logger->error('an error occured');


use MattFerris\Logging\Logger;
use MattFerris\Logging\Handlers\FileHandler;
use Psr\Log\LogLevel;

$logger = new Logger([
    [
        'handler' => new FileHandler('log.txt'),
        'levels' => [ LogLevel::EMERGENCY, LogLevel::CRITICAL, LogLevel::ERROR ]
    ]
]);

$logger = new Logger([
    [
        'handler' => new FileHandler('log.txt'),
        'maxlevel' => LogLevel::ERROR
    ]
]);

$logger->error('the user {user} does not exist', ['user' => 'joe']);

use MattFerris\Logging\Helpers\InterpolationHelper;

$logger = new Logger($handlers, [ new InterpolationHelper() ]);