Strange problem of log funtion

Hello people,

I am the developer of the official snips plugin, glad to be with you all to discuss.

I actually met a very strange problem with Log function from the very beginning. But still I did not solve it.

The problem is: even I called log::add(‹ snips ›, ‹ info ›, ‹ Message xxxx ›); Nothing happened or logged under snips section.

This is a bit test I have done:

I tried to use scenario code to simulate a log::add call:

And I added a few lines of the code in log.class just to have more information:

public static function add($_log, $_type, $_message, $_logicalId = ''){
        fwrite(STDOUT, '[Logger] Entered\n');
        fwrite(STDOUT, '[Logger] Message:'. $_message .'\n');
        fwrite(STDOUT, '[Logger] Loger:'. $_log .'\n');
        if (trim($_message) == '') {
                return;
        }
        $logger = self::getLogger($_log);
        $action = 'add' . ucwords(strtolower($_type));
        if (method_exists($logger, $action)) {
                fwrite(STDOUT, '[Logger] Logger exist\n');
                $logger->$action($_message);
                try {
                        $level = Logger::toMonologLevel($_type);
                        if ($level == Logger::ERROR && self::getConfig('addMessageForErrorLog') == 1) {
                                @message::add($_log, $_message, '', $_logicalId);
                        } elseif ($level > Logger::ALERT) {
                                @message::add($_log, $_message, '', $_logicalId);
                        }
                } catch (Exception $e) {
                        fwrite(STDOUT, '[Logger ERROR]'.$e->getMessage().'\n');
                }
        }
}

After execute this scenario, I have:

But still, nothing under snips is changed…
2

I hope you guys can help me figure out the problem. Thanks in advance.

Hi,

the debug level (second argument) need to be set in your plugin configuration (at least)

PS : please add your plugin tag to the subject :wink:

hello,

You are right. Thank you very much!

Seems a stupid question ever under this topic. :innocent:

Every question seems stupid once you know the answer :wink:

1 « J'aime »