Download the PHP package debugger84/zf2-graylog without Composer
On this page you can find all versions of the php package debugger84/zf2-graylog. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download debugger84/zf2-graylog
More information about debugger84/zf2-graylog
Files in debugger84/zf2-graylog
Package zf2-graylog
Short Description A Zend\Log writer and formatter helps you add Graylog logging to your ZF2 application.
License MIT
Homepage https://github.com/debugger84/ZF2Graylog
Informations about the package zf2-graylog
Graylog2 for Zend Framework 2
A Zend\Log
writer and formatter helps you add Graylog logging to your ZF2
application, using bzikarsky/gelf-php: the newer version of deprecated Graylog2/gelf-php library.
Install
Add values of graylog connection to your config
Rewrite factory for Zend Logger interface
Usage
I added a method to a custom base controller:
class Base extends \Zend\Mvc\Controller\AbstractActionController {
private $logger;
protected function getLogger() {
if (!isset($this->logger)) {
$this->logger = new \Zend\Log\Logger;
// __construct($facility, $hostname, $port)
$writer = new \ZF2Graylog\Log\Writer\Graylog2('ZF2', '127.0.0.1');
$this->logger->addWriter($writer);
}
return $this->logger;
}
}
Which can then be used as usual:
$this->getLogger()->info('Informative message');
The formatter should (or will) support error logging (as below) by mapping the following attributes to their respective GELF fields:
$logger = new \Zend\Log\Logger;
$writer = new \ZF2Graylog\Log\Writer\Graylog2('ZF2', '127.0.0.1');
$logger->addWriter($writer);
Zend\Log\Logger::registerErrorHandler($logger);
Zend\Log GELFMessage
--------------------------------------------------------------------------------
message message, full_message, short_message (unless present in $values)
errno level
file file
line line
context additional fields (to be tested)
Additional fields that are associated with GELF fields:
full
(message) is mapped tofull_message
(if present, otherwisemessage
)short
(message) is mapped toshort_message
(if present, otherwisemessage
)version
is mapped toversion
(not set if not present)facility
is mapped tofacility
. A default facility is set in the writer.- Additional fields are mapped as additional fields.
Todo
- Write a composer.json that includes the Graylog2/gelf-php lib.
- Docblocks.
- Further testing of different events.
- Check errno maps to the correct severity level when used as an errorHandler.
License
TBC, will probably be MIT.
All versions of zf2-graylog with dependencies
psr/container Version ^1.0
graylog2/gelf-php Version ^1.5