PHP code example of eddiejaoude / zf2-logger
1. Go to this page and download the library: Download eddiejaoude/zf2-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/ */
eddiejaoude / zf2-logger example snippets
//...
'modules' => array(
'EddieJaoude\Zf2Logger',
),
//...
//...
$serviceLocator->get('EddieJaoude\Zf2Logger')->emerg('Emergency message');
//...
//...
$serviceLocator->get('Logger')->emerg('Emergency message');
//...
'aliases' => array(
// ...
'Logger' => 'Zf2Logger',
// ...
),
// ...
'Zf2Logger' => function($sm) {
$logger = $sm->get('EddieJaoude\Zf2Logger');
$logger->addCustomExtra(
array(
'host' => !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'CLI',
)
);
return $logger;
},
// ...
return array(
'EddieJaoude\Zf2Logger' => array(
// will add the $logger object before the current PHP error handler
'registerErrorHandler' => 'true', // errors logged to your writers
'registerExceptionHandler' => 'true', // exceptions logged to your writers
// do not log binary responses
// mime types reference http://www.sitepoint.com/web-foundations/mime-types-complete-list/
'doNotLog' => array(
'mediaTypes' => array(
'application/octet-stream',
'image/png',
'image/jpeg',
'application/pdf'
),
),
// multiple zend writer output & zend priority filters
'writers' => array(
'standard-file' => array(
'adapter' => '\Zend\Log\Writer\Stream',
'options' => array(
'output' => 'data/application.log', // path to file
),
// options: EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
'filter' => \Zend\Log\Logger::DEBUG,
'enabled' => true
),
'tmp-file' => array(
'adapter' => '\Zend\Log\Writer\Stream',
'options' => array(
'output' => '/tmp/application-' . $_SERVER['SERVER_NAME'] . '.log', // path to file
),
// options: EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
'filter' => \Zend\Log\Logger::DEBUG,
'enabled' => false
),
'standard-output' => array(
'adapter' => '\Zend\Log\Writer\Stream',
'options' => array(
'output' => 'php://output'
),
// options: EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
'filter' => \Zend\Log\Logger::NOTICE,
'enabled' => $_SERVER['APPLICATION_ENV'] == 'development' ? true : false
),
'standard-error' => array(
'adapter' => '\Zend\Log\Writer\Stream',
'options' => array(
'output' => 'php://stderr'
),
// options: EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
'filter' => \Zend\Log\Logger::NOTICE,
'enabled' => true
)
)
)
);
curl -sS https://getcomposer.org/installer | php
php composer.phar install