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

Adding details about the second parameter for Laminas\Log\Formatter\Simple, the DateTime object format #42

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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