Socket
Socket
Sign inDemoInstall

@parcel/logger

Package Overview
Dependencies
Maintainers
1
Versions
881
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/logger - npm Package Compare versions

Comparing version 2.0.0-alpha.3.1 to 2.0.0-nightly.65

19

lib/Logger.js

@@ -17,3 +17,3 @@ "use strict";

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

@@ -187,7 +187,20 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

let error = messages[0];
return (0, _diagnostic.errorToDiagnostic)(error);
let diagnostic = (0, _diagnostic.errorToDiagnostic)(error);
if (Array.isArray(diagnostic)) {
return diagnostic.map(d => {
return _objectSpread({}, d, {
skipFormatting: true
});
});
} else {
return _objectSpread({}, diagnostic, {
skipFormatting: true
});
}
} else {
return {
message: joinLogMessages(messages),
origin: 'console'
origin: 'console',
skipFormatting: true
};

@@ -194,0 +207,0 @@ }

8

package.json
{
"name": "@parcel/logger",
"version": "2.0.0-alpha.3.1",
"version": "2.0.0-nightly.65+53632227",
"description": "Blazing fast, zero configuration web application bundler",

@@ -19,6 +19,6 @@ "license": "MIT",

"dependencies": {
"@parcel/diagnostic": "^2.0.0-alpha.3.1",
"@parcel/events": "^2.0.0-alpha.3.1"
"@parcel/diagnostic": "^2.0.0-nightly.65+53632227",
"@parcel/events": "^2.0.0-nightly.65+53632227"
},
"gitHead": "291f3e6815a1a857a6165fafb1691ceeb878b8f6"
"gitHead": "53632227bab3382066ed9c40456f54af9fa5614c"
}
// @flow strict-local
import type {IDisposable, LogEvent} from '@parcel/types';
import type {Diagnostic, Diagnostifiable} from '@parcel/diagnostic';
import type {
Diagnostic,
Diagnostifiable,
DiagnosticWithoutOrigin,
} from '@parcel/diagnostic';

@@ -10,7 +14,2 @@ import {ValueEmitter} from '@parcel/events';

export type PluginInputDiagnostic = {|
...Diagnostic,
origin?: string
|};
class Logger {

@@ -27,3 +26,3 @@ #logEmitter = new ValueEmitter<LogEvent>();

level: 'verbose',
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
});

@@ -40,3 +39,3 @@ }

level: 'info',
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
});

@@ -49,3 +48,3 @@ }

level: 'warn',
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
});

@@ -64,3 +63,3 @@ }

...diagnostic,
origin: realOrigin
origin: realOrigin,
};

@@ -72,3 +71,3 @@ }

level: 'error',
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
});

@@ -81,3 +80,3 @@ }

level: 'progress',
message
message,
});

@@ -91,3 +90,3 @@ }

export type PluginLoggerOpts = {|
origin: string
origin: string,
|};

@@ -103,3 +102,3 @@

updateOrigin(
diagnostic: PluginInputDiagnostic | Array<PluginInputDiagnostic>
diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
): Diagnostic | Array<Diagnostic> {

@@ -114,3 +113,3 @@ return Array.isArray(diagnostic)

verbose(
diagnostic: PluginInputDiagnostic | Array<PluginInputDiagnostic>
diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
): void {

@@ -120,11 +119,17 @@ logger.verbose(this.updateOrigin(diagnostic));

info(diagnostic: PluginInputDiagnostic | Array<PluginInputDiagnostic>): void {
info(
diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
): void {
logger.info(this.updateOrigin(diagnostic));
}
log(diagnostic: PluginInputDiagnostic | Array<PluginInputDiagnostic>): void {
log(
diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
): void {
logger.log(this.updateOrigin(diagnostic));
}
warn(diagnostic: PluginInputDiagnostic | Array<PluginInputDiagnostic>): void {
warn(
diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
): void {
logger.warn(this.updateOrigin(diagnostic));

@@ -136,4 +141,4 @@ }

| Diagnostifiable
| PluginInputDiagnostic
| Array<PluginInputDiagnostic>
| DiagnosticWithoutOrigin
| Array<DiagnosticWithoutOrigin>,
): void {

@@ -187,12 +192,26 @@ // $FlowFixMe it should work, don't really wanna mess with the types of logger.error though...

function messagesToDiagnostic(
messages: Array<mixed>
messages: Array<mixed>,
): Diagnostic | Array<Diagnostic> {
if (messages.length === 1 && messages[0] instanceof Error) {
let error: Error = messages[0];
let diagnostic = errorToDiagnostic(error);
return errorToDiagnostic(error);
if (Array.isArray(diagnostic)) {
return diagnostic.map(d => {
return {
...d,
skipFormatting: true,
};
});
} else {
return {
...diagnostic,
skipFormatting: true,
};
}
} else {
return {
message: joinLogMessages(messages),
origin: 'console'
origin: 'console',
skipFormatting: true,
};

@@ -199,0 +218,0 @@ }

@@ -22,3 +22,3 @@ // @flow

message: 'hello',
origin: 'logger'
origin: 'logger',
};

@@ -32,4 +32,4 @@

diagnostics: [diagnostic],
type: 'log'
})
type: 'log',
}),
);

@@ -41,3 +41,3 @@ });

message: 'zomg',
origin: 'logger'
origin: 'logger',
};

@@ -48,3 +48,3 @@

assert(
onLog.calledWith({level: 'warn', diagnostics: [diagnostic], type: 'log'})
onLog.calledWith({level: 'warn', diagnostics: [diagnostic], type: 'log'}),
);

@@ -56,3 +56,3 @@ });

message: 'oh noes',
origin: 'logger'
origin: 'logger',
};

@@ -63,3 +63,7 @@

assert(
onLog.calledWith({level: 'error', diagnostics: [diagnostic], type: 'log'})
onLog.calledWith({
level: 'error',
diagnostics: [diagnostic],
type: 'log',
}),
);

@@ -71,5 +75,5 @@ });

assert(
onLog.calledWith({level: 'progress', message: 'update', type: 'log'})
onLog.calledWith({level: 'progress', message: 'update', type: 'log'}),
);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc