@parcel/logger
Advanced tools
Comparing version 2.0.0-nightly.72 to 2.0.0-nightly.79
@@ -7,3 +7,4 @@ "use strict"; | ||
exports.patchConsole = patchConsole; | ||
exports.PluginLogger = exports.default = void 0; | ||
exports.unpatchConsole = unpatchConsole; | ||
exports.INTERNAL_ORIGINAL_CONSOLE = exports.PluginLogger = exports.default = void 0; | ||
@@ -146,15 +147,16 @@ var _events = require("@parcel/events"); | ||
exports.PluginLogger = PluginLogger; | ||
let consolePatched = false; // Patch `console` APIs within workers to forward their messages to the Logger | ||
let consolePatched = false; | ||
const INTERNAL_ORIGINAL_CONSOLE = _objectSpread({}, console); // Patch `console` APIs within workers to forward their messages to the Logger | ||
// at the appropriate levels. | ||
// TODO: Implement the rest of the console api as needed. | ||
// TODO: Does this need to be disposable/reversible? | ||
exports.INTERNAL_ORIGINAL_CONSOLE = INTERNAL_ORIGINAL_CONSOLE; | ||
function patchConsole() { | ||
if (consolePatched) { | ||
return; | ||
} | ||
// Skip if console is already patched... | ||
if (consolePatched) return; | ||
/* eslint-disable no-console */ | ||
// $FlowFixMe | ||
console.log = console.info = (...messages) => { | ||
@@ -185,2 +187,18 @@ logger.info(messagesToDiagnostic(messages)); | ||
function unpatchConsole() { | ||
// Skip if console isn't patched... | ||
if (!consolePatched) return; // $FlowFixMe | ||
console.log = INTERNAL_ORIGINAL_CONSOLE.log; // $FlowFixMe | ||
console.info = INTERNAL_ORIGINAL_CONSOLE.info; // $FlowFixMe | ||
console.debug = INTERNAL_ORIGINAL_CONSOLE.debug; // $FlowFixMe | ||
console.warn = INTERNAL_ORIGINAL_CONSOLE.warn; // $FlowFixMe | ||
console.error = INTERNAL_ORIGINAL_CONSOLE.error; | ||
consolePatched = false; | ||
} | ||
function messagesToDiagnostic(messages) { | ||
@@ -187,0 +205,0 @@ if (messages.length === 1 && messages[0] instanceof Error) { |
{ | ||
"name": "@parcel/logger", | ||
"version": "2.0.0-nightly.72+a0d19756", | ||
"version": "2.0.0-nightly.79+287ac639", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -19,6 +19,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@parcel/diagnostic": "2.0.0-nightly.72+a0d19756", | ||
"@parcel/events": "2.0.0-nightly.72+a0d19756" | ||
"@parcel/diagnostic": "2.0.0-nightly.79+287ac639", | ||
"@parcel/events": "2.0.0-nightly.79+287ac639" | ||
}, | ||
"gitHead": "a0d19756a842b80ae8114b9e664a3b84057fcb70" | ||
"gitHead": "287ac6397ade28595d56ac73971edb832bda8ff7" | ||
} |
@@ -143,11 +143,9 @@ // @flow strict-local | ||
let consolePatched = false; | ||
export const INTERNAL_ORIGINAL_CONSOLE = {...console}; | ||
// Patch `console` APIs within workers to forward their messages to the Logger | ||
// at the appropriate levels. | ||
// TODO: Implement the rest of the console api as needed. | ||
// TODO: Does this need to be disposable/reversible? | ||
export function patchConsole() { | ||
if (consolePatched) { | ||
return; | ||
} | ||
// Skip if console is already patched... | ||
if (consolePatched) return; | ||
@@ -180,2 +178,24 @@ /* eslint-disable no-console */ | ||
export function unpatchConsole() { | ||
// Skip if console isn't patched... | ||
if (!consolePatched) return; | ||
// $FlowFixMe | ||
console.log = INTERNAL_ORIGINAL_CONSOLE.log; | ||
// $FlowFixMe | ||
console.info = INTERNAL_ORIGINAL_CONSOLE.info; | ||
// $FlowFixMe | ||
console.debug = INTERNAL_ORIGINAL_CONSOLE.debug; | ||
// $FlowFixMe | ||
console.warn = INTERNAL_ORIGINAL_CONSOLE.warn; | ||
// $FlowFixMe | ||
console.error = INTERNAL_ORIGINAL_CONSOLE.error; | ||
consolePatched = false; | ||
} | ||
function messagesToDiagnostic( | ||
@@ -182,0 +202,0 @@ messages: Array<mixed>, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
16192
7
453
3
7
1