mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Merge pull request #4125 from yurydelendik/issue4111
Fixes and refactors log functionality
This commit is contained in:
commit
c57fdcceed
5 changed files with 30 additions and 46 deletions
|
@ -27,11 +27,13 @@
|
|||
//
|
||||
//var EXPORTED_SYMBOLS = ['NetworkManager'];
|
||||
//
|
||||
//function log(aMsg) {
|
||||
// var msg = 'network.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
||||
// Services.console.logStringMessage(msg);
|
||||
// // TODO(mack): dump() doesn't seem to work here...
|
||||
// dump(msg + '\n');
|
||||
//var console = {
|
||||
// log: function console_log(aMsg) {
|
||||
// var msg = 'network.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
||||
// Services.console.logStringMessage(msg);
|
||||
// // TODO(mack): dump() doesn't seem to work here...
|
||||
// dump(msg + '\n');
|
||||
// }
|
||||
//}
|
||||
//#endif
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
/* globals assertWellFormed, bytesToString, CipherTransformFactory, error, info,
|
||||
InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef,
|
||||
isStream, Lexer, log, Page, Parser, Promise, shadow,
|
||||
isStream, Lexer, Page, Parser, Promise, shadow,
|
||||
stringToPDFString, stringToUTF8String, warn, isString, assert,
|
||||
Promise, MissingDataException, XRefParseException, Stream,
|
||||
ChunkedStream, LegacyPromise */
|
||||
|
@ -999,7 +999,7 @@ var XRef = (function XRefClosure() {
|
|||
if (e instanceof MissingDataException) {
|
||||
throw e;
|
||||
}
|
||||
log('(while reading XRef): ' + e);
|
||||
info('(while reading XRef): ' + e);
|
||||
}
|
||||
|
||||
if (recoveryMode)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals error, globalScope, InvalidPDFException, log,
|
||||
/* globals error, globalScope, InvalidPDFException, info,
|
||||
MissingPDFException, PasswordException, PDFJS, Promise,
|
||||
UnknownErrorException, NetworkManager, LocalPdfManager,
|
||||
NetworkPdfManager, XRefParseException, LegacyPromise,
|
||||
|
@ -332,7 +332,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||
// Pre compile the pdf page and fetch the fonts/images.
|
||||
page.getOperatorList(handler).then(function(operatorList) {
|
||||
|
||||
log('page=%d - getOperatorList: time=%dms, len=%d', pageNum,
|
||||
info('page=%d - getOperatorList: time=%dms, len=%d', pageNum,
|
||||
Date.now() - start, operatorList.fnArray.length);
|
||||
|
||||
}, function(e) {
|
||||
|
@ -374,7 +374,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||
var start = Date.now();
|
||||
page.extractTextContent().then(function(textContent) {
|
||||
deferred.resolve(textContent);
|
||||
log('text indexing: page=%d - time=%dms', pageNum,
|
||||
info('text indexing: page=%d - time=%dms', pageNum,
|
||||
Date.now() - start);
|
||||
}, function (e) {
|
||||
// Skip errored pages
|
||||
|
@ -422,15 +422,18 @@ var workerConsole = {
|
|||
timeEnd: function timeEnd(name) {
|
||||
var time = consoleTimer[name];
|
||||
if (!time) {
|
||||
error('Unkown timer name ' + name);
|
||||
error('Unknown timer name ' + name);
|
||||
}
|
||||
this.log('Timer:', name, Date.now() - time);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Worker thread?
|
||||
if (typeof window === 'undefined') {
|
||||
globalScope.console = workerConsole;
|
||||
if (!('console' in globalScope)) {
|
||||
globalScope.console = workerConsole;
|
||||
}
|
||||
|
||||
// Listen for unsupported features so we can pass them on to the main thread.
|
||||
PDFJS.UnsupportedManager.listen(function (msg) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue