a-r-m-i-n / scssphp-bundle

Symfony bundle to parse scss sources at runtime.
2 stars 3 forks source link

Collect SCSS warnings (using SCSSPHP's LoggerInterface ) #3

Open stof opened 3 years ago

stof commented 3 years ago

As of scssphp 1.5, there is an official extension point to customize the reporting of sass warnings.

Reporting them in the profiler might be an option.

stof commented 3 years ago

Note that I'm not using the bundle myself. However, as one of the maintainers of scssphp, I still find it interesting that the bundle that comes out on packagist when searching for scssphp respects the best practices about this reporting (i.e. making sure they are not hidden)

a-r-m-i-n commented 2 years ago

Those method calls (called in \Armin\ScssphpBundle\Scss\Job::execute) are marked as deprecated:

I guess you mean using the CompilationResult, right?

a-r-m-i-n commented 2 years ago

there is an official extension point to customize the reporting of sass warnings

apparently it's not CompilationResult. Do you have a link to docs for me? Or an example? @stof

stof commented 2 years ago

The reporting of Sass warnings is handled by the LoggerInterface. See https://scssphp.github.io/scssphp/docs/extending/ for the doc about extension points.

a-r-m-i-n commented 2 years ago

Okay, I've checked the LoggerInterface, but I think this is nothing I need to implement, because I am not using monolog at all, currently.

Errors and warnings occuring during compiling process, are already fetched, by catching \ScssPhp\ScssPhp\Exception\SassException. All infos are displayed in debug toolbar, if installed. Or in CLI command, always.

The old calls of deprecated scssphp methods, are fixed. Thanks for helping!

stof commented 2 years ago

Sass warnings are not triggering a SassException (otherwise, they would not be warnings as an exception interrupts the compilation). Sass warnings are reported through the Scssphp LoggerInterface (which is not related to Monolog). To me, you would need a custom implementation of that interface to collect the warnings to render them in the webprofiler, instead of using the default one sending to to STDERR.

a-r-m-i-n commented 2 years ago

Okay, I got it!

a-r-m-i-n commented 2 years ago

@stof Maybe, this would be a nice addition for scssphp's api too. A memory log writer.