Merge pull request #4045 from brendandahl/verbosity

Add verbosity as an api setting.
This commit is contained in:
Yury Delendik 2014-01-02 12:25:00 -08:00
commit c389451a5b
4 changed files with 27 additions and 6 deletions

View File

@ -230,6 +230,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
PDFJS.maxImageSize = data.maxImageSize === undefined ? PDFJS.maxImageSize = data.maxImageSize === undefined ?
-1 : data.maxImageSize; -1 : data.maxImageSize;
PDFJS.disableFontFace = data.disableFontFace; PDFJS.disableFontFace = data.disableFontFace;
PDFJS.verbosity = data.verbosity;
getPdfManager(data).then(function pdfManagerReady() { getPdfManager(data).then(function pdfManagerReady() {
loadDocument(false).then(onSuccess, function loadFailure(ex) { loadDocument(false).then(onSuccess, function loadFailure(ex) {

View File

@ -93,6 +93,18 @@ PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
*/ */
PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ?
true : PDFJS.postMessageTransfers; true : PDFJS.postMessageTransfers;
/**
* Controls the logging level.
* The constants from PDFJS.VERBOSITY_LEVELS should be used:
* - errors
* - warnings [default]
* - infos
* @var {Number}
*/
PDFJS.verbosity = PDFJS.verbosity === undefined ?
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity;
/** /**
* This is the main entry point for loading a PDF and interacting with it. * This is the main entry point for loading a PDF and interacting with it.
* NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR) * NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR)
@ -870,7 +882,8 @@ var WorkerTransport = (function WorkerTransportClosure() {
source: source, source: source,
disableRange: PDFJS.disableRange, disableRange: PDFJS.disableRange,
maxImageSize: PDFJS.maxImageSize, maxImageSize: PDFJS.maxImageSize,
disableFontFace: PDFJS.disableFontFace disableFontFace: PDFJS.disableFontFace,
verbosity: PDFJS.verbosity
}); });
}, },

View File

@ -22,9 +22,6 @@ var globalScope = (typeof window === 'undefined') ? this : window;
var isWorker = (typeof window == 'undefined'); var isWorker = (typeof window == 'undefined');
var ERRORS = 0, WARNINGS = 1, INFOS = 5;
var verbosity = WARNINGS;
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
var TextRenderingMode = { var TextRenderingMode = {
@ -49,6 +46,12 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS.pdfBug = false; globalScope.PDFJS.pdfBug = false;
PDFJS.VERBOSITY_LEVELS = {
errors: 0,
warnings: 1,
infos: 5
};
// All the possible operations for an operator list. // All the possible operations for an operator list.
var OPS = PDFJS.OPS = { var OPS = PDFJS.OPS = {
// Intentionally start from 1 so it is easy to spot bad operators that will be // Intentionally start from 1 so it is easy to spot bad operators that will be
@ -157,7 +160,7 @@ var log = (function() {
// for things that are helpful to devs, such as warning that Workers were // for things that are helpful to devs, such as warning that Workers were
// disabled, which is important to devs but not end users. // disabled, which is important to devs but not end users.
function info(msg) { function info(msg) {
if (verbosity >= INFOS) { if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.infos) {
log('Info: ' + msg); log('Info: ' + msg);
PDFJS.LogManager.notify('info', msg); PDFJS.LogManager.notify('info', msg);
} }
@ -165,7 +168,7 @@ function info(msg) {
// Non-fatal warnings that should trigger the fallback UI. // Non-fatal warnings that should trigger the fallback UI.
function warn(msg) { function warn(msg) {
if (verbosity >= WARNINGS) { if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.warnings) {
log('Warning: ' + msg); log('Warning: ' + msg);
PDFJS.LogManager.notify('warn', msg); PDFJS.LogManager.notify('warn', msg);
} }

View File

@ -1604,6 +1604,10 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
USE_ONLY_CSS_ZOOM = (hashParams['useOnlyCssZoom'] === 'true'); USE_ONLY_CSS_ZOOM = (hashParams['useOnlyCssZoom'] === 'true');
} }
if ('verbosity' in hashParams) {
PDFJS.verbosity = hashParams['verbosity'] | 0;
}
//#if !(FIREFOX || MOZCENTRAL) //#if !(FIREFOX || MOZCENTRAL)
var locale = navigator.language; var locale = navigator.language;
if ('locale' in hashParams) if ('locale' in hashParams)