Bug #74860 [Com]: Uncaught exceptions not being formatted properly when error_log set to "syslog"
| From: | philipp at redfish-solutions dot com | Date: | Wed, 05 Jul 2017 20:43:12 +0000 |
| Subject: | Bug #74860 [Com]: Uncaught exceptions not being formatted properly when error_log set to "syslog" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209832@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74860&edit=1
ID: 74860
Comment by: philipp at redfish-solutions dot com
Reported by: philipp at redfish-solutions dot com
Summary: Uncaught exceptions not being formatted properly
when error_log set to "syslog"
Status: Open
Type: Bug
Package: Output Control
Operating System: linux 4.9.30
PHP Version: 7.1.6
Block user comment: N
Private report: N
New Comment:
Citing RFC 3164:
4.1.3 MSG Part of a syslog Packet
The MSG part will fill the remainder of the syslog packet. This will
usually contain some additional information of the process that
generated the message, and then the text of the message. There is no
ending delimiter to this part. The MSG part of the syslog packet
MUST contain visible (printing) characters. [...]
Previous Comments:
------------------------------------------------------------------------
[2017-07-05 20:36:39] philipp at redfish-solutions dot com
Description:
------------
I'm using php-7.1.6 on Linux (LEDE master). During development, I had an uncaught exception
which generated the diagnostic:
2017-07-05T11:56:20-06:00 PowercodeBMU Powercode: Error: Call to undefined function fetch() in
/www/lib/php/LogController.php:48
Stack trace:
#0 /tmp/foo.php(7): LogIterator->valid()
#1 {main}
i.e. 4 lines of text with embedded newlines. syslog() doesn't handle this correctly, as each
line is supposed to be prefixed with a timestamp, hostname, and tag... but only the first line is
formatted correctly because syslog() is handling the buffer as a single string.
The correct behavior is to explode this message on newlines and then write each part to syslog
individually.
My php.ini file contained:
error_log = "syslog";
Test script:
---------------
Just about any uncaught exception should trigger this.
Expected result:
----------------
Correct logging should look like:
2017-07-05T11:56:20-06:00 PowercodeBMU Powercode: Error: Call to undefined function fetch() in
/www/lib/php/LogController.php:48
2017-07-05T11:56:20-06:00 PowercodeBMU Powercode: Stack trace:
2017-07-05T11:56:20-06:00 PowercodeBMU Powercode: #0 /tmp/foo.php(7): LogIterator->valid()
2017-07-05T11:56:20-06:00 PowercodeBMU Powercode: #1 {main}
note that each line is prefixed identically.
Actual result:
--------------
Per description.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74860&edit=1