PHP code example of fei / logger-client

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

    

fei / logger-client example snippets


// sample configuration for production environment
$logger = new Logger(array(
                            Logger::OPTION_BASEURL  => 'http://logger.flash-global.net',
                            Logger::OPTION_FILTER   => Notification::LVL_DEBUG,
                          )
                    );
// inject transport classes
$logger->setTransport(new BasicTransport());

// optionnal asynchronous transport, that will be automatically used to push notifications
//
// NOTE this transport 


$logger = $container->get('logger');

$logger->notify('Notification message'); // default level is Notification::LVL_INFO
$logger->notify('Debug message', array('level' => Notification::LVL_DEBUG));


$logger = $container->get('logger');

$notification = new Notification(array('message' => 'Notification message'));
$notification
        ->setLevel(Notification::LVL_WARNING)
        ->setContext(array('key' => 'value')
        ;
        
$logger->notify($notification);



use Fei\Service\Logger\Client\Logger;
use Fei\Service\Logger\Client\Psr\PsrLoggerAdapter;

$logger = new Logger();

$psr = new PsrLoggerAdapter($logger);

$psr->error('This is a error message');



use Fei\Service\Logger\Client\Logger;
use Fei\Service\Logger\Client\Psr\PsrLoggerAdapter;
use Fei\Service\Logger\Entity\Notification;

$logger = new Logger();

$psr = new PsrLoggerAdapter($logger);

$psr->error(
    'This is a error message',
    [
        'namespace' => '/my/app',
        'category' => Notification::TRACKING,
        'key1' => 'value1',
        'key2' => 'value2'
    ]
);