Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #42 from galvao/2.16.x
Browse files Browse the repository at this point in the history
Adding details about the second parameter for Laminas\Log\Formatter\Simple, the DateTime object format
  • Loading branch information
Ocramius authored Aug 15, 2022
2 parents 813af96 + 2555521 commit 105e210
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/book/formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ $logger->info('there');
// outputs "hello there"
```

The constructor of `Laminas\Log\Formatter\Simple` accepts a single parameter: the
format string. This string contains keys surrounded by percent signs (e.g.
`%message%`). The format string may contain any key from the event data array.
The constructor of `Laminas\Log\Formatter\Simple` accepts two parameters: the
format string and the format for DateTime objects in event data. The format
string contains keys surrounded by percent signs (e.g.
`%message%`) and may contain any key from the event data array.
You can retrieve the default keys by using the `DEFAULT_FORMAT` constant from
`Laminas\Log\Formatter\Simple`.

The DateTime format string follows PHP's [DateTimeInterface::format](https://www.php.net/manual/en/datetime.format.php)
pattern and defaults to the format described in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). You can
retrieve the default DateTime format by using the
`DEFAULT_DATETIME_FORMAT` constant from `Laminas\Log\Formatter\FormatterInterface`.

## Formatting to JSON

`Laminas\Log\Formatter\Json` is the JSON formatter. By default, it
Expand Down

0 comments on commit 105e210

Please sign in to comment.