In the Logger.php, there is a function called addRecord which takes in DateTimeImmutable. This object is an object of the Monolog package.
In that function, you have stated that this argument is log date to log in the past or the future. However, when creating the Monolog DateTimeImmutable object, there is no way to set the date for this object. It always default to now. There is no way for me to pass through the base DateTimeImmutable object to the addRecord function as it is strict typed to Monolog\DateTimeImmutable.
public function __construct(bool $useMicroseconds, ?DateTimeZone $timezone = null)
{
$this->useMicroseconds = $useMicroseconds;
parent::__construct('now', $timezone);
}
public function addRecord(int $level, string $message, array $context = [], DateTimeImmutable $datetime = null): bool
I feel like there is some inconsistency here as the function allows a future or a past date, yet the DateTimeImmutable object itself doesn't. Are we meant to use it like this?
Monolog version 1|2|3?
Write your question here.
Hi,
In the Logger.php, there is a function called
addRecord
which takes in DateTimeImmutable. This object is an object of the Monolog package.In that function, you have stated that this argument is log date to log in the past or the future. However, when creating the Monolog DateTimeImmutable object, there is no way to set the date for this object. It always default to
now
. There is no way for me to pass through the base DateTimeImmutable object to the addRecord function as it is strict typed to Monolog\DateTimeImmutable.I feel like there is some inconsistency here as the function allows a future or a past date, yet the DateTimeImmutable object itself doesn't. Are we meant to use it like this?