reg-viz / storycap

A Storybook Addon, Save the screenshot image of your stories :camera: via puppeteer.
https://www.npmjs.com/package/storycap
MIT License
705 stars 89 forks source link

Forward console logs from the story context to the user's CLI #790

Closed Mike-Dax closed 1 year ago

Mike-Dax commented 1 year ago

This builds on https://github.com/reg-viz/storycap/pull/789, happy to rebase as needed.

Currently the screenshot utility swallows all console logs and errors from the 'story' context. This makes debugging screenshots extremely difficult. (It's also quite difficult to mount a debugger to the internal story isolate.)

This PR forwards console messages by default into the debug Logger channel, and optionally allows for a --forwardConsoleLogs option to surface them to the user's CLI with matched error, warn or info log levels.

Messages currently look like:

error From examples-thrusttestbench--screenshot-light (error): THREE.WebGLRenderer: Error creating WebGL context.

image

Happy to bikeshed the cli option name, format of the logs, etc.