Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: The formatted message is not valid #14522

Closed
Jeckerson opened this issue Nov 10, 2019 · 1 comment
Closed

[BUG]: The formatted message is not valid #14522

Jeckerson opened this issue Nov 10, 2019 · 1 comment
Labels
bug A bug report status: medium Medium

Comments

@Jeckerson
Copy link
Member

Jeckerson commented Nov 10, 2019

Describe the bug
Impossible to pass log message as string, nor as array with Logger->log() method.

To Reproduce
Steps to reproduce the behavior:

Example 1:

<?php

use Phalcon\Logger;
use Phalcon\Logger\Adapter\Syslog;
use Phalcon\Logger\Formatter\Line as LineFormatter;

$formatter = new LineFormatter("[devtools@localhost]: [%type%] %message%", 'D j H:i:s');
$adapter = new Syslog('php://stderr');
$adapter->setFormatter($formatter);

$logger = new Logger('messages', ['main' => $adapter]);
$logger->log(Logger::NOTICE, 'Notice message');

Produce error:

Uncaught Phalcon\Logger\Exception: The formatted message is not valid in phalcon/Logger/Adapter/Syslog.zep:107
Stack trace:
#0 [internal function]: Phalcon\Logger\Adapter\Syslog->process(Object(Phalcon\Logger\Item))
#1 [internal function]: Phalcon\Logger->addMessage(5, 'Notice message', Array)
#2 /srv/public/log_test.php(12): Phalcon\Logger->log(5, 'Notice message')
#3 {main}
  thrown in phalcon/Logger/Adapter/Syslog.zep on line 107

Example 2:

// Try to pass as array, according example - https://docs.phalcon.io/4.0/en/logger#interpolation
$logger->log(Logger::NOTICE, [
    'type' => 'notice',
    'message' => 'Notice message',
]);

Produce error:

Array to string conversion
PHP message: PHP Fatal error:  Uncaught Phalcon\Logger\Exception: The formatted message is not valid in phalcon/Logger/Adapter/Syslog.zep:107
Stack trace:
#0 [internal function]: Phalcon\Logger\Adapter\Syslog->process(Object(Phalcon\Logger\Item))
#1 [internal function]: Phalcon\Logger->addMessage(5, 'Array', Array)
#2 /srv/public/log_test.php(13): Phalcon\Logger->log(5, Array)
#3 {main}
  thrown in phalcon/Logger/Adapter/Syslog.zep on line 107

Expected behavior
Log message into stderr without any fatal errors.

Details

  • Phalcon version: 4.0.0-rc.2
  • PHP Version: 7.2.19
  • Operating System: Ubuntu 18
  • Installation type: Compiling from source
  • Server: Nginx
@niden
Copy link
Member

niden commented Nov 11, 2019

Resolved #14525

@niden niden closed this as completed Nov 11, 2019
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

2 participants