sitrunlab / LearnZF2

Learn ZF2 Website
http://learnzf2.sitrun-tech.com/
BSD 3-Clause "New" or "Revised" License
19 stars 14 forks source link

Log demo module #113

Closed samsonasik closed 9 years ago

samsonasik commented 9 years ago

Fixes #106

samsonasik commented 9 years ago

I'm trying to re-set formatters of the Logger but it seems it not changed on loop formatters, and when changin on loop by addWriter, it got hang. @acelaya do you have an idea to re-set writers's formatter/filter so it can switch? hint : SplPriorityQueue...

acelaya commented 9 years ago

I've been taking a look at a project where I used a logger. Have you tried by setting the priority as a config property at the same level of options and name? The Logger constructor seems to look there for it. Instead of this

'writers' => [
    [
        'name' => 'stream',
        'options' => [
            'stream' => 'php://output',
            'filters' => [
                'priority' => [
                    'name' => 'priority',
                    'options' => [
                        'priority' => \Zend\Log\Logger::DEBUG,
                    ],
                ],
            ],
            'formatter' => [
                'name' => 'simple',
                'options' => [
                    'format' => '%timestamp% %priorityName% (%priority%): %message%'.PHP_EOL,
                ],
            ],
        ],
    ],
],

Try with this

'writers' => [
    [
        'name' => 'stream',
        'priority' => \Zend\Log\Logger::DEBUG,
        'options' => [
            'stream' => 'php://output',
            'formatter' => [
                'name' => 'simple',
                'options' => [
                    'format' => '%timestamp% %priorityName% (%priority%): %message%'.PHP_EOL,
                ],
            ],
        ],
    ],
],
samsonasik commented 9 years ago

Ok, I will try if that possible be change-able on form posted change priority/formatter. Thank you.

samsonasik commented 9 years ago

I'm thinking about not inject controller with Logger instance, but use 'log' config as controller property, and create new Logger on the fly when form submitted, so Logger instance can be created by :

$this->loggerConfig['writers'][0]['options']['formatter']['name'] = $data['logformat'];
$logger = new Logger($this->loggerConfig);

I will do it..

samsonasik commented 9 years ago

it succeed, log generated : log-generated I will write test for it ;)

samsonasik commented 9 years ago

it's done, ready for review ;)

samsonasik commented 9 years ago

@acelaya any review for this ? merge-able ?

acelaya commented 9 years ago

Sorry, I won't be able to test it until tomorrow evening, sorry. However I'm sure it works fine ;)

Alejandro Celaya Alastrué www.alejandrocelaya.com El 23/2/2015 11:21, "Abdul Malik Ikhsan" notifications@github.com escribió:

@acelaya https://github.com/acelaya any review for this ? merge-able ?

— Reply to this email directly or view it on GitHub https://github.com/sitrunlab/LearnZF2/pull/113#issuecomment-75518391.

samsonasik commented 9 years ago

It's ok for tomorrow ;). to reproduce it, there is updated ./data/sql/learnzf2.sql for addition module. Thank you.

Warm Regards,

Abdul Malik Ikhsan

2015-02-23 17:23 GMT+07:00 Alejandro Celaya notifications@github.com:

Sorry, I won't be able to test it until tomorrow evening, sorry. However I'm sure it works fine ;)

Alejandro Celaya Alastrué www.alejandrocelaya.com El 23/2/2015 11:21, "Abdul Malik Ikhsan" notifications@github.com escribió:

@acelaya https://github.com/acelaya any review for this ? merge-able ?

— Reply to this email directly or view it on GitHub https://github.com/sitrunlab/LearnZF2/pull/113#issuecomment-75518391.

— Reply to this email directly or view it on GitHub https://github.com/sitrunlab/LearnZF2/pull/113#issuecomment-75518576.

acelaya commented 9 years ago

It properly works. It can be merged!

samsonasik commented 9 years ago

@acelaya merged. Thanks ;)