PHP code example of enlitepro / enlite-slow-log

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

    

enlitepro / enlite-slow-log example snippets




return array(
    'EnliteSlowLog' => array(
        // service manager alias
        // accept zend logger and PSR-3 logger like monolog
        'logger' => 'EnliteMonologService',
        // in milliseconds
        'threshold' => 1000
    )
);

// prepare logger via Zend\Log\LoggerAbstractServiceFactory
// in config/autoload/log.global.php
'log' => array(
    'MySlowLog' => array(
        'writers' => array(
            array(
                'name' => 'Zend\Log\Writer\Stream',
                'options' => array(
                    "stream" => "data/slow.log"
                )
            )
        )
    )
),

// in config/autoload/enlite-slow-log.global.php
'EnliteSlowLog' => array(
    'logger' => 'MySlowLog',
    'threshold' => 1000
),

// in config/autoload/enlite-monolog.global.php
'EnliteMonolog' => array(
    'MySlowLog' => array(
        'name' => 'SlowLog', // will be output to log
        'handlers' => array(
            'default' => array(
                'name' => 'Monolog\Handler\StreamHandler',
                'args' => array(
                    'path' => 'data/slow.log'
                )
            )
        )
    )
),

// in config/autoload/enlite-slow-log.global.php
'EnliteSlowLog' => array(
    'logger' => 'MySlowLog',
    'threshold' => 1000
)


// in Module.php
public function getServiceConfig()
{
    return array(
        'factories' => array(
            'MySlowLogger' => function(){
                $logger = new \Zend\Log\Logger();
                $writer = new \Zend\Log\Writer\Stream("data/slow.log");
                $logger->addWriter($writer);

                return $writer;
            }
        )
    );
}

// in enlite-slow-log.global.php

'EnliteSlowLog' => array(
    'logger' => 'MySlowLogger',
    'threshold' => 1000
)