New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't log messages to the console that the user or developer can do nothing about #11292
Comments
I suppose that it depends on what sort of "developer" we're talking about here, since I can assure you that from the PDF.js-contributor perspective many of the console messages are most helpful.
It's, generally speaking, the responsibility of the person actually utilizing the PDF.js library to ensure that their code is using correct and current APIs, and otherwise update their own code such that deprecated messages aren't seen by end-users.
The amount of logging printed in the console can be easily controlled by the API user when calling Lines 152 to 153 in 72bd8e8
Lines 182 to 186 in 72bd8e8
For example, calling getDocument in the following way will only print actual error messages:
const loadingTask = getDocument({
url,
verbosity: 0,
});
This is an open source project, with most people contributing in their spare time. Please understand that writing good documentation can be both time-consuming and non-trivial, so if the documentation is lacking please consider contributing to it :-)
It's not clear what you mean by "production environments" here, but if you're e.g. referring to the pre-built
There already is such a thing[1], for unsupported features, please see Lines 463 to 467 in 72bd8e8
For an example of how this can be used, please see the default viewer code here and here. [1] This is e.g. being used to display a notification bar, for features which aren't supported, in the built-in Firefox PDF Viewer. |
Closing as answered; I also agree with everything said above. |
We're developing an app that uses pdf.js - we use the browser console extensively during development but don't log anything to it (unless absolutely necessary) in production. We deal with millions of PDFs from different sources, often converted poorly or corrupted before we get them.
pdf.js is excellent, but logs warnings and errors to the console that the developer or end user can do nothing about.
For instance #3768 - a bad font recovery message. That's useful information, but not to the end user viewing the PDF or the application developer.
Other warnings are useful but with an unhelpful and persistent message, for instance #10377 if you
await page.render(...
you get told thatthen
syntax is deprecated. The fix (toawait page.render(...).promise
) and related documentation to it should be indicated, and if the deprecated method is still called in production then end users don't need to know about it.What is the expected behaviour?
In the production build:
The text was updated successfully, but these errors were encountered: