PHP code example of flexic / log

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

    

flexic / log example snippets


# Configure a logger

$logger = new \Flexic\Log\Logger('test');

$logger->pushHandler(new \Flexic\Log\Handler\FileHandler('/path/to/log/file/'));

$logger->log(\Flexic\Log\LogLevel::DEBUG, 'Message with {placeholder}', array('placeholder' => 'text'));

# Logger functions

$logger->emergency('Message with {placeholder}', array('placeholder' => 'text'));
$logger->alert('Message with {placeholder}', array('placeholder' => 'text'));
$logger->critical('Message with {placeholder}', array('placeholder' => 'text'));
$logger->error('Message with {placeholder}', array('placeholder' => 'text'));
$logger->warning('Message with {placeholder}', array('placeholder' => 'text'));
$logger->notice('Message with {placeholder}', array('placeholder' => 'text'));
$logger->info('Message with {placeholder}', array('placeholder' => 'text'));
$logger->debug('Message with {placeholder}', array('placeholder' => 'text'));
$logger->exception('Message with {placeholder}', array('placeholder' => 'text'));
$logger->log(\Flexic\Log\LogLevel::DEBUG, 'Message with {placeholder}', array('placeholder' => 'text'));

# Configure a static logger

$logger = new \Flexic\Log\Logger('test');
$logger->pushHandler(new \Flexic\Log\Handler\FileHandler('/path/to/log/file/'));

Flexic\Log\StaticLogger::setLogger($logger);

Flexic\Log\StaticLogger::log(\Flexic\Log\LogLevel::DEBUG, 'Message with {placeholder}', array('placeholder' => 'text'));