-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Restrict logging of errors with verbosity level #5886
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
Conversation
Can't we simplify this a lot by keeping a similar structure as Line 196 in fa0f09b
|
In my opinion this code looks much more elegant // Fatal errors.
function err(fn) {
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
fn();
}
}
// Fatal errors that should trigger the fallback UI and halt execution by
// throwing an exception.
function error(msg) {
// If multiple arguments were passed, pass them all to the log function.
if (arguments.length > 1) {
var logArguments = ['Error:'];
logArguments.push.apply(logArguments, arguments);
err(console.log.apply.bind(console.log, console, logArguments));
// Join the arguments into a single string for the lines below.
msg = [].join.call(arguments, ' ');
} else {
err(console.log.bind(console, 'Error: ' + msg));
}
err(console.log.bind(console, backtrace()));
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
throw new Error(msg);
} than this one // Fatal errors that should trigger the fallback UI and halt execution by
// throwing an exception.
function error(msg) {
// If multiple arguments were passed, pass them all to the log function.
if (arguments.length > 1) {
var logArguments = ['Error:'];
logArguments.push.apply(logArguments, arguments);
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
console.log.apply(console, logArguments);
}
// Join the arguments into a single string for the lines below.
msg = [].join.call(arguments, ' ');
} else {
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
console.log('Error: ' + msg);
}
}
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
console.log(backtrace());
}
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
throw new Error(msg);
} Please, let me now, which you prefer. |
Neither solution above look good. Can you review calls of error() function and make it as a single argument function (similar to info/warn)? If multiple arguments are used, make it something like Currently, the patch contains |
A very quick look through the code-base seem to indicate that no caller of |
@yurydelendik , @timvandermeij , @Snuffleupagus Reviewed code and found no caller with multiple arguments. Changed code to simple // Fatal errors that should trigger the fallback UI and halt execution by
// throwing an exception.
function error(msg) {
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
console.log(msg);
console.log(backtrace());
}
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
throw new Error(msg);
} multiple console logs for separate lines. Or can be done with "\n". |
} else { | ||
console.log('Error: ' + msg); | ||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) { | ||
console.log(msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be console.log('Error: ' + msg);
.
@andrewdacenko Please squash the commits into one, see: https://github.com/mozilla/pdf.js/wiki/Squashing-Commits. |
@Snuffleupagus Done. @timvandermeij , @yurydelendik thanks for your attention ) |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/e73bf3dac6e3775/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/7d10084e29f7068/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/e73bf3dac6e3775/output.txt Total script time: 2.87 mins
Image differences available at: http://107.22.172.223:8877/e73bf3dac6e3775/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/7d10084e29f7068/output.txt Total script time: 22.24 mins
|
/botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/2c6750c128842c7/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/2c6750c128842c7/output.txt Total script time: 17.92 mins
|
Restrict logging of errors with verbosity level
Thanks for the patch! |
Allow control errors logging with PDFJS.verbosity level