Socket
Socket
Sign inDemoInstall

@pnp/logging

Package Overview
Dependencies
Maintainers
13
Versions
1035
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnp/logging - npm Package Compare versions

Comparing version 2.1.0-beta8 to 2.1.0-beta9

34

listeners.js

@@ -5,5 +5,3 @@ /**

*/
var ConsoleListener = /** @class */ (function () {
function ConsoleListener() {
}
export class ConsoleListener {
/**

@@ -14,4 +12,4 @@ * Any associated data that a given logging listener may choose to log or ignore

*/
ConsoleListener.prototype.log = function (entry) {
var msg = this.format(entry);
log(entry) {
const msg = this.format(entry);
switch (entry.level) {

@@ -29,3 +27,3 @@ case 0 /* Verbose */:

}
};
}
/**

@@ -36,4 +34,4 @@ * Formats the message

*/
ConsoleListener.prototype.format = function (entry) {
var msg = [];
format(entry) {
const msg = [];
msg.push("Message: " + entry.message);

@@ -45,10 +43,8 @@ if (entry.data !== undefined) {

catch (e) {
msg.push(" Data: Error in stringify of supplied data " + e);
msg.push(` Data: Error in stringify of supplied data ${e}`);
}
}
return msg.join("");
};
return ConsoleListener;
}());
export { ConsoleListener };
}
}
/**

@@ -58,3 +54,3 @@ * Implementation of LogListener which logs to the supplied function

*/
var FunctionListener = /** @class */ (function () {
export class FunctionListener {
/**

@@ -66,3 +62,3 @@ * Creates a new instance of the FunctionListener class

*/
function FunctionListener(method) {
constructor(method) {
this.method = method;

@@ -75,8 +71,6 @@ }

*/
FunctionListener.prototype.log = function (entry) {
log(entry) {
this.method(entry);
};
return FunctionListener;
}());
export { FunctionListener };
}
}
//# sourceMappingURL=listeners.js.map

@@ -8,4 +8,4 @@ /**

/**
* Gets or sets the active log level to apply for log filtering
*/
* Gets or sets the active log level to apply for log filtering
*/
static get activeLogLevel(): LogLevel;

@@ -15,40 +15,40 @@ static set activeLogLevel(value: LogLevel);

/**
* Adds ILogListener instances to the set of subscribed listeners
*
* @param listeners One or more listeners to subscribe to this log
*/
* Adds ILogListener instances to the set of subscribed listeners
*
* @param listeners One or more listeners to subscribe to this log
*/
static subscribe(...listeners: ILogListener[]): void;
/**
* Clears the subscribers collection, returning the collection before modification
*/
* Clears the subscribers collection, returning the collection before modification
*/
static clearSubscribers(): ILogListener[];
/**
* Gets the current subscriber count
*/
* Gets the current subscriber count
*/
static get count(): number;
/**
* Writes the supplied string to the subscribed listeners
*
* @param message The message to write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
* Writes the supplied string to the subscribed listeners
*
* @param message The message to write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
static write(message: string, level?: LogLevel): void;
/**
* Writes the supplied string to the subscribed listeners
*
* @param json The json object to stringify and write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
* Writes the supplied string to the subscribed listeners
*
* @param json The json object to stringify and write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
static writeJSON(json: any, level?: LogLevel): void;
/**
* Logs the supplied entry to the subscribed listeners
*
* @param entry The message to log
*/
* Logs the supplied entry to the subscribed listeners
*
* @param entry The message to log
*/
static log(entry: ILogEntry): void;
/**
* Logs an error object to the subscribed listeners
*
* @param err The error object
*/
* Logs an error object to the subscribed listeners
*
* @param err The error object
*/
static error(err: Error): void;

@@ -72,12 +72,12 @@ }

/**
* The main message to be logged
*/
* The main message to be logged
*/
message: string;
/**
* The level of information this message represents
*/
* The level of information this message represents
*/
level: LogLevel;
/**
* Any associated data that a given logging listener may choose to log or ignore
*/
* Any associated data that a given logging listener may choose to log or ignore
*/
data?: any;

@@ -91,8 +91,8 @@ }

/**
* Any associated data that a given logging listener may choose to log or ignore
*
* @param entry The information to be logged
*/
* Any associated data that a given logging listener may choose to log or ignore
*
* @param entry The information to be logged
*/
log(entry: ILogEntry): void;
}
//# sourceMappingURL=logger.d.ts.map

@@ -5,128 +5,98 @@ /**

*/
var Logger = /** @class */ (function () {
function Logger() {
export class Logger {
/**
* Gets or sets the active log level to apply for log filtering
*/
static get activeLogLevel() {
return Logger.instance.activeLogLevel;
}
Object.defineProperty(Logger, "activeLogLevel", {
/**
* Gets or sets the active log level to apply for log filtering
*/
get: function () {
return Logger.instance.activeLogLevel;
},
set: function (value) {
Logger.instance.activeLogLevel = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Logger, "instance", {
get: function () {
if (Logger._instance === undefined || Logger._instance === null) {
Logger._instance = new LoggerImpl();
}
return Logger._instance;
},
enumerable: false,
configurable: true
});
/**
* Adds ILogListener instances to the set of subscribed listeners
*
* @param listeners One or more listeners to subscribe to this log
*/
Logger.subscribe = function () {
var listeners = [];
for (var _i = 0; _i < arguments.length; _i++) {
listeners[_i] = arguments[_i];
static set activeLogLevel(value) {
Logger.instance.activeLogLevel = value;
}
static get instance() {
if (Logger._instance === undefined || Logger._instance === null) {
Logger._instance = new LoggerImpl();
}
listeners.forEach(function (listener) { return Logger.instance.subscribe(listener); });
};
return Logger._instance;
}
/**
* Clears the subscribers collection, returning the collection before modification
*/
Logger.clearSubscribers = function () {
* Adds ILogListener instances to the set of subscribed listeners
*
* @param listeners One or more listeners to subscribe to this log
*/
static subscribe(...listeners) {
listeners.forEach(listener => Logger.instance.subscribe(listener));
}
/**
* Clears the subscribers collection, returning the collection before modification
*/
static clearSubscribers() {
return Logger.instance.clearSubscribers();
};
Object.defineProperty(Logger, "count", {
/**
* Gets the current subscriber count
*/
get: function () {
return Logger.instance.count;
},
enumerable: false,
configurable: true
});
}
/**
* Writes the supplied string to the subscribed listeners
*
* @param message The message to write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
Logger.write = function (message, level) {
if (level === void 0) { level = 1 /* Info */; }
* Gets the current subscriber count
*/
static get count() {
return Logger.instance.count;
}
/**
* Writes the supplied string to the subscribed listeners
*
* @param message The message to write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
static write(message, level = 1 /* Info */) {
Logger.instance.log({ level: level, message: message });
};
}
/**
* Writes the supplied string to the subscribed listeners
*
* @param json The json object to stringify and write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
Logger.writeJSON = function (json, level) {
if (level === void 0) { level = 1 /* Info */; }
* Writes the supplied string to the subscribed listeners
*
* @param json The json object to stringify and write
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
*/
static writeJSON(json, level = 1 /* Info */) {
this.write(JSON.stringify(json), level);
};
}
/**
* Logs the supplied entry to the subscribed listeners
*
* @param entry The message to log
*/
Logger.log = function (entry) {
* Logs the supplied entry to the subscribed listeners
*
* @param entry The message to log
*/
static log(entry) {
Logger.instance.log(entry);
};
}
/**
* Logs an error object to the subscribed listeners
*
* @param err The error object
*/
Logger.error = function (err) {
* Logs an error object to the subscribed listeners
*
* @param err The error object
*/
static error(err) {
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
};
return Logger;
}());
export { Logger };
var LoggerImpl = /** @class */ (function () {
function LoggerImpl(activeLogLevel, subscribers) {
if (activeLogLevel === void 0) { activeLogLevel = 2 /* Warning */; }
if (subscribers === void 0) { subscribers = []; }
}
}
class LoggerImpl {
constructor(activeLogLevel = 2 /* Warning */, subscribers = []) {
this.activeLogLevel = activeLogLevel;
this.subscribers = subscribers;
}
LoggerImpl.prototype.subscribe = function (listener) {
subscribe(listener) {
this.subscribers.push(listener);
};
LoggerImpl.prototype.clearSubscribers = function () {
var s = this.subscribers.slice(0);
}
clearSubscribers() {
const s = this.subscribers.slice(0);
this.subscribers.length = 0;
return s;
};
Object.defineProperty(LoggerImpl.prototype, "count", {
get: function () {
return this.subscribers.length;
},
enumerable: false,
configurable: true
});
LoggerImpl.prototype.write = function (message, level) {
if (level === void 0) { level = 1 /* Info */; }
}
get count() {
return this.subscribers.length;
}
write(message, level = 1 /* Info */) {
this.log({ level: level, message: message });
};
LoggerImpl.prototype.log = function (entry) {
}
log(entry) {
if (entry !== undefined && this.activeLogLevel <= entry.level) {
this.subscribers.map(function (subscriber) { return subscriber.log(entry); });
this.subscribers.map(subscriber => subscriber.log(entry));
}
};
return LoggerImpl;
}());
}
}
/**

@@ -133,0 +103,0 @@ * A set of logging levels

{
"name": "@pnp/logging",
"version": "2.1.0-beta8",
"version": "2.1.0-beta9",
"description": "pnp - light-weight, subscribable logging framework",

@@ -5,0 +5,0 @@ "main": "./index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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