php-fig/log — pull request #21 by sun (2014-05-15 20:32:08+00:00)
Title: Fixes #8: PSR-3 claims to follow RFC 5424 but LogLevel constants do not.

[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) claims to use RFC 5424 log levels:

> The `LoggerInterface` exposes eight methods to write logs to the eight [RFC 5424](http://tools.ietf.org/html/rfc5424) levels (debug, info, notice, warning, error, critical, alert, emergency).

Problem: The log message severity levels are defined as strings, which causes PSR-3 to violate RFC 5424.

http://tools.ietf.org/html/rfc5424#section-6.2.1 clearly defines:
>
Numerical Severity
Code
0 Emergency: system is unusable
1 Alert: action must be taken immediately
2 Critical: critical conditions
3 Error: error conditions
4 Warning: warning conditions
5 Notice: normal but significant condition
6 Informational: informational messages
7 Debug: debug-level messages
>
Table 2. syslog Message Severities

RFC 5424 is the successor of [RFC 3164](http://tools.ietf.org/html/rfc3164#section-4.1.1). The IETF standard for log message severities exists since 2001.

It's not clear why PSR-3 was entirely modeled after RFC 5424, and even includes literal copies of text fragments, but suddenly diverges from it in `LogLevel` constant values.

As [discussed here](https://github.com/php-fig/log/issues/8#issuecomment-42897728) this causes PSR-3 to **not** meet the goal of interoperability (it's primary objective).

There are two options:

A. Change the constant values to adhere to RFC 5424. (code change)
B. Stop pretending that PSR-3 has anything to do with RFC 5424. (textual spec change)

---
(Incomplete) List of projects that are following the IETF standard:

* [Zend Framework 2](https://github.com/zendframework/zf2/blob/master/library/Zend/Log/Logger.php#L24)
* [Lithium](https://github.com/UnionOfRAD/lithium/blob/master/analysis/Logger.php#L73)
* [Phalcon](https://github.com/phalcon/cphalcon/blob/master/ext/logger.h#L25-L32)
* [CakePHP](https://github.com/cakephp/cakephp/blob/master/lib/Cake/Log/CakeLog.php#L91)
* [Drupal](https://github.com/drupal/drupal/blob/8.0-alpha11/core/includes/bootstrap.inc#L82-L120)
* [IDK Framework](https://github.com/peeter-tomberg/IDK-Framework/blob/master/AppConfig/Logger.php#L5-L16)
* [TYPO3 CMS](https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/core/Classes/Log/LogLevel.php#l31)
* [TYPO3 Flow](https://git.typo3.org/Packages/TYPO3.Flow.git/blob/HEAD:/Classes/TYPO3/Flow/Log/Logger.php#l86) *(implicitly by using PHP `LOG_` constants)*
* [php-logger-essentials](https://github.com/rkrx/php-logger-essentials) _…only exists to correct this problem._

Out of all other analyzed projects, most are using custom integers (e.g., Monolog, Joomla, Mediawiki).

Excluding the (1-2) projects that migrated to PSR-3 already, this research yielded only 1-2 projects using strings (which I forgot to record + can't remember).