monolog icon indicating copy to clipboard operation
monolog copied to clipboard

Allow to specify time for log records

Open Chi-teck opened this issue 1 year ago • 1 comments

That would be nice to allow users mock time for log records.

\Monolog\Logger::addRecord has an optional parameter for log timestamp. However, methods that implement Psr\Log\LoggerInterface do not have such a parameter.

I think the best way to fix this is passing optional $clock parameter to the logger constructor that implements PSR 20 interface. Then addRecord could fetch timestamp from the clock service

Chi-teck avatar Jul 31 '24 16:07 Chi-teck

Sounds reasonable to me if you want to send a PR :)

Seldaek avatar Nov 09 '24 13:11 Seldaek