Bug #77913 [Opn]: error_log via syslog: PHP will split msg on line break
| From: | whissi at whissi dot de | Date: | Tue, 16 Apr 2019 19:49:17 +0000 |
| Subject: | Bug #77913 [Opn]: error_log via syslog: PHP will split msg on line break | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220497@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77913&edit=1
ID: 77913
User updated by: whissi at whissi dot de
Reported by: whissi at whissi dot de
Summary: error_log via syslog: PHP will split msg on line
break
Status: Open
Type: Bug
Package: *General Issues
PHP Version: 7.3.4
Block user comment: N
Private report: N
New Comment:
And if this was a desired change, maybe rename "syslog.filter=no-ctrl" to
"syslog.filter=no-ctrl-but-line-breaks" :-)
I.e. you either _filter_ all ctrl chars like the option says or none. But filtering some but
handle/interpret others isn't good.
Previous Comments:
------------------------------------------------------------------------
[2019-04-16 19:43:40] whissi at whissi dot de
Not when this is a backward incompatible change.
Of course, if this was a desired change, please add it to https://www.php.net/manual/en/migration73.incompatible.php
and in addition please provide a way to send multi-line messages.
------------------------------------------------------------------------
[2019-04-16 19:36:08] requinix@php.net
Isn't it a good thing that the line break is being recognized and handled?
------------------------------------------------------------------------
[2019-04-16 17:40:33] whissi at whissi dot de
Even with "syslog.filter=no-ctrl" when you would expect a syslog message like
> Apr 16 16:54:09 myhost php: This is line #1This is line #2
because PHP has filtered control chars like line break, you end up with two messages, so filtering
doesn't work as expected.
------------------------------------------------------------------------
[2019-04-16 17:35:56] whissi at whissi dot de
Description:
------------
PHP 7.3 introduced "syslog.filter" to control content send to syslog.
According to documentation
(https://www.php.net/manual/en/errorfunc.configuration.php#ini.syslog.filter),
"syslog.filter=all" should allow all characters (=same behavior like in PHP 7.2 or
before). However, even when set "syslog.filter=all" to allow all characters including line
breaks, when you now send a multi-line message via error_log() through syslog, PHP splits message on
line break so you end up with multiple messages instead of sending one single message like before.
Test script:
---------------
<?php
$message = "This is line #1" . PHP_EOL;
$message .= "This is line #2";
$iniSetting = ini_get('error_log');
if ($iniSetting !== 'syslog') {
die("You must set error_log=syslog!");
}
if (version_compare(phpversion(), '7.3', '>')) {
$iniSetting = ini_get('syslog.filter');
if ($iniSetting !== 'all') {
die("You must set syslog.filter=all!");
}
}
error_log($message);
print "Now please review your syslog!" . PHP_EOL;
Expected result:
----------------
When running test script like
> /usr/bin/php7.3 -d error_log=syslog -d syslog.filter=all test.php
I would expect one single syslog message like
> Apr 16 16:52:06 myhost php: This is line #1#012This is line #2
Actual result:
--------------
I am getting _two_ messages:
> Apr 16 16:53:20 myhost php: This is line #1
> Apr 16 16:53:20 myhost php: This is line #2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77913&edit=1