zendframework / zend-log

Log component from Zend Framework
BSD 3-Clause "New" or "Revised" License
62 stars 51 forks source link

AbstractServiceFactory for PsrLoggerAdapter #70

Closed Sohorev closed 4 years ago

Sohorev commented 7 years ago

Please create AbstractServiceFactory for Zend\Log\PsrLoggerAdapter

froschdesign commented 7 years ago

@Sohorev Why is this needed?

Sohorev commented 7 years ago

Because AbstractServiceFactory for zend log it is comfortably But if I use PsrLoggerAdapter that I have to create log in factory style. It seems uncomfortable.

For example with zend log I have one line config for all my logs:

        'abstract_factories' => [
            Zend\Log\LoggerAbstractServiceFactory::class,
        ]

But with PsrLoggerAdapter i have a following ponderous config :

        'factories' => [
            'logger' => \My\Log\LoggerFactory::class,
            'error-logger' => \MyLog\LoggerFactory::class,
            'sql-logger' => \My\Log\LoggerFactory::class,
           ......
        ],

Additionally, in either case a following config exists (This can not be avoided):

    'log' => [
        'logger' => [
            'writers' => [
.....
            ],
        ],
        'error-logger' => [
            'writers' => [
.....
            ],
        ],
        'sql-logger' => [
            'writers' => [
.....
        ],
        ..............
    ],
froschdesign commented 7 years ago

Because AbstractServiceFactory for zend log it is comfortably But if I use PsrLoggerAdapter that I have to create log in factory style. It seems uncomfortable.

Ah, now I understand. I was confused why a AbstractServiceFactory should be needed for the PsrLoggerAdapter. You mean a ready to use factory for the PSR adapter.


Btw. you do not need this:

'abstract_factories' => [
    Zend\Log\LoggerAbstractServiceFactory::class,
]

Use zend-log as module.

application.config.php:

'modules' => [
    'Zend\Log',
]
Sohorev commented 7 years ago

You mean a ready to use factory for the PSR adapter.

yes

Use zend-log as module.

I have use zend expressive and zend PsrLoggerAdapter as my logger. But factory style for every logger uncomfortably. When i try to add following:

$configManager = new ConfigManager([
....
    \Zend\Log\ConfigProvider::class,
.....
], 'data/config-cache.php');

it create Zend\Log\Logger objects but I am need for Zend\Log\PsrLoggerAdapter objects

samsonasik commented 4 years ago

can be closed in favor of https://github.com/zendframework/zend-log/pull/99