https://github.com/seyfer/zendpsrlogger
This is module that implement PSR-3 log interface with Zend\log component. Also implement Doctrine log writer.
https://github.com/seyfer/zendpsrlogger
doctrine-log-writer entity php zend-framework2 zend-framework3
Last synced: 9 months ago
JSON representation
This is module that implement PSR-3 log interface with Zend\log component. Also implement Doctrine log writer.
- Host: GitHub
- URL: https://github.com/seyfer/zendpsrlogger
- Owner: seyfer
- License: gpl-2.0
- Created: 2014-06-19T07:10:51.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2019-06-16T19:17:48.000Z (almost 7 years ago)
- Last Synced: 2025-04-12T13:45:20.716Z (12 months ago)
- Topics: doctrine-log-writer, entity, php, zend-framework2, zend-framework3
- Language: PHP
- Homepage: https://packagist.org/packages/seyfer/zend-psr-logger
- Size: 88.9 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ZendPsrLogger
=============
This is module that implement PSR-3 log interface with Zend\log component.
Also implement Doctrine log writer.
Installation
------------
Get from packagist or github.
`require "seyfer/zend-psr-logger": "dev-master"`
http://modules.zendframework.com/seyfer/ZendPsrLogger
If using Zend2, than enable in application.config.php,
add 'ZendPsrLogger' to modules.
Configuration
-------------
Extra column mapping and Entity name in module.config.php.
Extra column `ipaddress` for example.
```
'logger' => array(
'registeredLoggers' => array(
'DefaultLogger' => array(
'entityClassName' => '\ZendPsrLogger\Entity\DefaultLog',
'columnMap' => array(
'timestamp' => 'timestamp',
'priority' => 'priority',
'priorityName' => 'priorityName',
'message' => 'message',
'extra' => array(
'ipaddress' => 'ipaddress',
),
)
),
'ElseDefaultLogger' => array(
'entityClassName' => '\ZendPsrLogger\Entity\ElseDefaultLog',
'columnMap' => array(
'timestamp' => 'timestamp',
'priority' => 'priority',
'priorityName' => 'priorityName',
'message' => 'message',
'extra' => array(
'fileName' => 'fileName',
),
)
)
),
),
```
Than set abstract factory with your module logger custom name in Module.php
```
public function getServiceConfig()
{
return array(
'abstract_factories' => array(
'DefaultLogger' => '\ZendPsrLogger\Service\AbstractLoggerFactory',
'ElseDefaultLogger' => '\ZendPsrLogger\Service\AbstractLoggerFactory',
),
);
}
```
Factory will use your module.config.php `logger` config.
You can implement your factory and using writers,
that implement Zend\Log\Writer\AbstractWriter.
To implement your Doctrine log entity you can extend it from
`Logger\Entity\BaseLog` and just add your extra column mapping.
```
logger
...
if ($this->getServiceLocator()->has($myLoggerName)) {
$logger = $this->getServiceLocator()->get($myLoggerName);
} else {
$logger = new NullLogger();
}
$this->logger = $logger;
```
Than use it's level function
```
$this->logger->addExtra(['ipaddress' => '11.22.33.44']);
$this->logger->debug("test");
```
Or log directly using \Psr\Log\LogLevel constants for level parameter.
```
$this->logger->log(\Psr\Log\LogLevel::DEBUG, "test", ['ipaddress' => '11.22.33.44']);
```
License
-------
GPL. If you want implement more writers or other improvements - you're welcome!
Change Log
----------
v1.1.0
- use AbstractLoggerFactory and new config structure for multiple logger creation
v1.0.1
- implement Doctrine writer
- use LoggerFactory for logger creation