php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55129 LOG_ level constants don't comply with RFC 3164 on Windows
Submitted: 2011-07-04 11:51 UTC Modified: 2011-07-08 18:18 UTC
Votes:5
Avg. Score:4.2 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:5 (100.0%)
Same OS:5 (100.0%)
From: sun at unleashedmind dot com Assigned:
Status: Open Package: Win32API related
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sun at unleashedmind dot com
New email:
PHP Version: OS:

 

 [2011-07-04 11:51 UTC] sun at unleashedmind dot com
Description:
------------
On Windows, the LOG_* constant values differ from the values defined in RFC 3164.  The values are correct on Unix platforms.

Previously discussed in https://bugs.php.net/bug.php?id=18090 and closed as bogus back in 2002.

Over at Drupal, we replaced custom log level constants with PHP's native LOG_* constants: http://drupal.org/node/1136130 -- and had to learn the hard way that the constant values differ on Windows. (undocumented: http://php.net/manual/en/network.constants.php)

Drupal uses these severity levels for application-level logging.  The logger is pluggable, so messages may be stored in a database, third-party system, or simply passed to syslog().  Depending on the logger implementation, messages may also be listed/read.  Therefore, consistent log severity level constant values are required.

The question arose why PHP overrides the LOG_* constant values on Windows, kinda violating the RFC, and whether the reduction to values supported by Windows' event log could not happen in a Windows-specific syslog() implementation instead, not affecting the global run-time constants.

I understand that it's Windows that's to blame.  However, I don't see why PHP has to follow Windows' bogus lead on not respecting the RFC.  Conforming to industry standards would be a huge benefit for interoperability with other systems.

Concrete change request:

- Make PHP's LOG_* constant values always conform to RFC 3164.

- Move the platform-specific mapping/reduction into a syslog() implementation for Windows.


Test script:
---------------
<?php
var_dump(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG);
?>

Expected result:
----------------
int(0)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)


Actual result:
--------------
int(1)
int(1)
int(1)
int(4)
int(5)
int(6)
int(6)
int(6)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-08 18:18 UTC] kalle@php.net
Hi

I like the idea, perhaps we should cook something like this up together with @fat's patch for multiple connections to syslog() and confront the RFC in and interoperability way in 5.4.
 [2011-11-04 14:34 UTC] panman at traileyes dot com
FYI, just wanted to add that the SimpleSAMLphp project uses these constants as well for their logger.
 [2018-06-12 08:39 UTC] arash dot dalir at gmail dot com
It's 2018 and this issue is still open!
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Sep 22 10:01:26 2019 UTC