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

Comments

@Jeckerson
Copy link
Member

@Jeckerson 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 niden mentioned this issue Nov 11, 2019
5 of 5 tasks complete
@niden niden added this to To do in 4.0 Release via automation Nov 11, 2019
@niden

This comment has been minimized.

Copy link
Member

@niden niden commented Nov 11, 2019

Resolved #14525

@niden niden closed this Nov 11, 2019
4.0 Release automation moved this from To do to Done Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4.0 Release
  
Done
2 participants
You can’t perform that action at this time.