westy92 / html-pdf-chrome

HTML to PDF or image (jpeg, png, webp) converter via Chrome/Chromium
https://www.npmjs.com/package/html-pdf-chrome
MIT License
775 stars 60 forks source link

Log Handler #301

Open lucasbaesso opened 3 years ago

lucasbaesso commented 3 years ago

Hello @westy92 Is it possible to add a log handler to the project? Like this example:

  await Promise.all([
    Network.enable(),
    Page.enable(),
    Runtime.enable(),
    Log.enable()
  ]);
  if (options.clientLogHandler) {
    Log.entryAdded(options.clientLogHandler);
  }

Use case example:

var logHandler = (e) => {
    chromeLogger.debug(e.entry.source + ': ' + e.entry.text);
};

options.clientLogHandler = logHandler;

Chrome DevTools Log reference: https://chromedevtools.github.io/devtools-protocol/tot/Log/

westy92 commented 3 years ago

Feel free to submit a pull request!