Skip to content

Commit

Permalink
stephanrauh/ngx-extended-pdf-viewer#804 detect the worker thread more…
Browse files Browse the repository at this point in the history
… reliably
  • Loading branch information
stephanrauh committed Nov 20, 2021
1 parent 9a76fd8 commit a759368
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/shared/util.js
Expand Up @@ -390,7 +390,9 @@ function getVerbosityLevel() {
// end users.
function info(msg) {
if (verbosity >= VerbosityLevel.INFOS) {
if (Window && Window['ngxConsole']) {
if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {
console.log(`Info: ${msg}`);
} else if (Window && Window['ngxConsole']) {
Window['ngxConsole'].log(`Info: ${msg}`);
} else {
console.log(`Info: ${msg}`);
Expand All @@ -401,8 +403,10 @@ function info(msg) {
// Non-fatal warnings.
function warn(msg) {
if (verbosity >= VerbosityLevel.WARNINGS) {
if (Window && Window['ngxConsole']) {
Window['ngxConsole'].log(`Warning: ${msg}`);
if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {
console.log(`Warning: ${msg}`);
} else if (Window && Window["ngxConsole"]) {
Window["ngxConsole"].log(`Warning: ${msg}`);
} else {
console.log(`Warning: ${msg}`);
}
Expand Down

0 comments on commit a759368

Please sign in to comment.