Task #48876

Story #48874: As a developer I want a PSR-3 compatible Logging API

PSR-3: throw InvalidArgumentException on undefined severity

Added by Steffen Müller over 4 years ago. Updated over 4 years ago.

Status:
Resolved
Priority:
Could have
Assignee:
-
Category:
Logging API
Start date:
2013-06-05
Due date:
% Done:

100%

TYPO3 Version:
6.2

Description

PSR-3 expects \TYPO3\CMS\Core\Log\Logger::log($severity, ...) to throw an InvalidArgumentException when the given $severity is undefined.

The core logging API validates the severity in \TYPO3\CMS\Core\Log\LogLevel::validateLevel() and throws a RangeException in case of undefined severities, because it uses integer values as severity instead of strings.

Solution would be to use InvalidArgumentException if a string was given instead.

History

#1 Updated by Helmut Hummel over 4 years ago

Steffen Müller wrote:

PSR-3 expects \TYPO3\CMS\Core\Log\Logger::log($severity, ...) to throw an InvalidArgumentException when the given $severity is undefined.

It expects a Psr\Log\InvalidArgumentException to be thrown.

The core logging API validates the severity in \TYPO3\CMS\Core\Log\LogLevel::validateLevel() and throws a RangeException in case of undefined severities, because it uses integer values as severity instead of strings.
Solution would be to use InvalidArgumentException if a string was given instead.

Why not throwing a Psr\Log\InvalidArgumentException in any case?
Would still be semantically correct.

Or introduce a TYPO3\CMS\Log\InvalidLogLevelException which extends Psr\Log\InvalidArgumentException

#2 Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21847

#3 Updated by Gerrit Code Review over 4 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21847

#4 Updated by Steffen Müller over 4 years ago

  • Status changed from New to Under Review

#5 Updated by Gerrit Code Review over 4 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21847

#6 Updated by Gerrit Code Review over 4 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21847

#7 Updated by Steffen Müller over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

applied in changeset 9aabc565

Also available in: Atom PDF