Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

The Logger implements by me can't compatible with Phalcon\Logger\AdapterInterface::log($type, $message, array $context = NULL)

I want to implement my own logger by extending Phalcon\Logger\Adapter\File. And I want to implement a function as follow:

1.When use log method which level "<=" CRITICAL, the system will send MS to Admin

2.When use log method which level ">=" ALERT and "<=" WARNING, the system will send E-mail to Admin.

I used Phalcon\Events\Manager and override Phalcon\Logger\AdapterInterface::log to implement this function

    public function log($type, $message, $context = NULL){

        parent::log($type, $message, $context);

        // SendMS
        if($type <= Phalcon\Logger::CRITICAL){

            self::$_eventsManager->fire('Elex-Logger:sendMS', $this, $message);

        // SendEmail
        }else if($type >= Phalcon\Logger::ALERT && $type <= Phalcon\Logger::WARNING){

            self::$_eventsManager->fire('Elex-Logger:sendEmail', $this, $message);


When I usephalcon_x86 _VC9 _php5.4.0 _1.3.1 _nts on windows 7. It keeps saying:

Fatal error: Declaration of MyLogger::log() must be compatible with Phalcon\Logger\AdapterInterface::log($type, $message, array $context = NULL)

I had checked many times there is no differents between MyLogger::log() and Phalcon\Logger\AdapterInterface::log().

How could this happen ? Is this a bug of Phalcon 1.3.1?

Thanks and sorry for my english.


I solved the problem.

change log method sign to:

public function log ($type, $message, array $context = NULL)

add a "array" before $context var. But I don't know why......Does PHP have this syntax ?