PHP-CSS-Parser icon indicating copy to clipboard operation
PHP-CSS-Parser copied to clipboard

Add a debugging log

Open oliverklee opened this issue 1 year ago • 2 comments

For every error that currently is throwing an exception or that is worked around using the lenient mode, we should log the problem, the line number and the corresponding CSS fragment (where it makes sense).

We should log this using a PSR-compatible logger and provide a simple default logger to Parser. It should be possible to override the logger from the outside (so people can plug in their own logging if they like).

We'll also need to psr/log to our dependencies.

It should also be possible to disable debugging in order to improve performance.

oliverklee avatar Feb 12 '24 09:02 oliverklee

Would using psr/log allow us to provide a 'null' logger by default, possibly meaning we don't need to actually additionally provide an on/off switch?

JakeQZ avatar Feb 14 '24 00:02 JakeQZ

Yes, psr/log provides a NullLogger which we can use: https://github.com/php-fig/log/blob/master/src/NullLogger.php

For the non-null logger, we can extend https://github.com/php-fig/log/blob/master/src/AbstractLogger.php with our own SimpleLogger (or something along the lines) so people don't need to implement their own logging for simple debugging.

oliverklee avatar Feb 14 '24 07:02 oliverklee