Skip to content

Commit b78357a

Browse files
committed
Add PSR-3 meta document to include type upgrades.
1 parent 70a6285 commit b78357a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Logger Meta Document
2+
3+
## 1. Summary
4+
5+
The logger interface defines a common interface for logging system messages from an application or library.
6+
7+
This metadocument was written post-hoc, as PSR-3 was originally passed before meta-documents were standard practice.
8+
9+
## 2. Design Decisions
10+
11+
### Static log messages
12+
13+
It is the intent of this specification that the message passed to a logging method always be a static value. Any context-specific variability (such as a username, timestamp, or other information) should be provided via the `$context` array only, and the string should use a placeholder to reference it.
14+
15+
The intent of this design is twofold. One, the message is then readily available to translation systems to create localized versions of log messages. Two, context-specific data may contain user input, and thus requires escaping. That escaping will be necessarily different if the log message is stored in a database for later rendering in HTML, serialized to JSON, serialized to a syslog message string, etc. It is the responsibility of the logging implementation to ensure that `$context` data that is shown to the user is appropriately escaped.
16+
17+
## 3. People
18+
19+
### 3.1 Editor(s)
20+
21+
* Jordi Boggiano
22+
23+
## 4. Votes
24+
25+
[Approval vote](https://groups.google.com/g/php-fig/c/d0yPC7jWPAE/m/rhexAfz2T_8J)
26+
27+
## 5. Errata
28+
29+
### 7.1 Type additions
30+
31+
The 2.0 release of the `psr/log` package includes scalar parameter types. The 3.0 release of the package includes return types. This structure leverages PHP 7.2 covariance support to allow for a gradual upgrade process, but requires PHP 8.0 for type compatibility.
32+
33+
Implementers MAY add return types to their own packages at their discretion, provided that:
34+
35+
* the return types match those in the 3.0 package.
36+
* the implementation specifies a minimum PHP version of 8.0.0 or later.
37+
38+
Implementers MAY add parameter types to their own packages in a new major release, either at the same time as adding return types or in a subsequent release, provided that:
39+
40+
* the parameter types match those in the 2.0 package.
41+
* the implementation specifies a minimum PHP version of 8.0.0 or later.
42+
* the implementation depends on `"psr/link": "^2.0 || ^3.0"` so as to exclude the untyped 1.0 version.
43+
44+
Implementers are encouraged but not required to transition their packages toward the 3.0 version of the package at their earliest convenience.

0 commit comments

Comments
 (0)