Socket
Socket
Sign inDemoInstall

@pnp/logging

Package Overview
Dependencies
Maintainers
6
Versions
1046
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 1.0.0-beta.11 to 1.0.0-rc.0

4

dist/logging.es5.js
/**
@license
* @pnp/logging v1.0.0-beta.11 - pnp - light-weight, subscribable logging framework
* @pnp/logging v1.0.0-rc.0 - pnp - light-weight, subscribable logging framework
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE)

@@ -102,3 +102,3 @@ * Copyright (c) 2018 Microsoft

Logger.error = function (err) {
Logger.instance.log({ data: err, level: 3 /* Error */, message: "[" + err.name + "]::" + err.message });
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
};

@@ -105,0 +105,0 @@ return Logger;

/**
@license
* @pnp/logging v1.0.0-beta.11 - pnp - light-weight, subscribable logging framework
* @pnp/logging v1.0.0-rc.0 - pnp - light-weight, subscribable logging framework
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE)

@@ -210,3 +210,3 @@ * Copyright (c) 2018 Microsoft

Logger.error = function (err) {
Logger.instance.log({ data: err, level: 3 /* Error */, message: "[" + err.name + "]::" + err.message });
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
};

@@ -213,0 +213,0 @@ return Logger;

/**
@license
* @pnp/logging v1.0.0-beta.11 - pnp - light-weight, subscribable logging framework
* @pnp/logging v1.0.0-rc.0 - pnp - light-weight, subscribable logging framework
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE)

@@ -10,3 +10,3 @@ * Copyright (c) 2018 Microsoft

*/
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.pnp=n():e.pnp=n()}("undefined"!=typeof self?self:this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(1);t.d(n,"Logger",function(){return r.c}),t.d(n,"ConsoleListener",function(){return r.a}),t.d(n,"FunctionListener",function(){return r.b})},function(e,n,t){"use strict";var r=t(2);t.d(n,"c",function(){return r.a});var o=t(3);t.d(n,"a",function(){return o.a}),t.d(n,"b",function(){return o.b})},function(e,n,t){"use strict";t.d(n,"a",function(){return r});var r=function(){function e(){}return Object.defineProperty(e,"activeLogLevel",{get:function(){return e.instance.activeLogLevel},set:function(n){e.instance.activeLogLevel=n},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return void 0!==e._instance&&null!==e._instance||(e._instance=new o),e._instance},enumerable:!0,configurable:!0}),e.subscribe=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];n.map(function(n){return e.instance.subscribe(n)})},e.clearSubscribers=function(){return e.instance.clearSubscribers()},Object.defineProperty(e,"count",{get:function(){return e.instance.count},enumerable:!0,configurable:!0}),e.write=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:n})},e.writeJSON=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:JSON.stringify(n)})},e.log=function(n){e.instance.log(n)},e.error=function(n){e.instance.log({data:n,level:3,message:"["+n.name+"]::"+n.message})},e}(),o=function(){function e(e,n){void 0===e&&(e=2),void 0===n&&(n=[]),this.activeLogLevel=e,this.subscribers=n}return e.prototype.subscribe=function(e){this.subscribers.push(e)},e.prototype.clearSubscribers=function(){var e=this.subscribers.slice(0);return this.subscribers.length=0,e},Object.defineProperty(e.prototype,"count",{get:function(){return this.subscribers.length},enumerable:!0,configurable:!0}),e.prototype.write=function(e,n){void 0===n&&(n=0),this.log({level:n,message:e})},e.prototype.log=function(e){void 0!==e&&this.activeLogLevel<=e.level&&this.subscribers.map(function(n){return n.log(e)})},e}()},function(e,n,t){"use strict";t.d(n,"a",function(){return r}),t.d(n,"b",function(){return o});var r=function(){function e(){}return e.prototype.log=function(e){var n=this.format(e);switch(e.level){case 0:case 1:console.log(n);break;case 2:console.warn(n);break;case 3:console.error(n)}},e.prototype.format=function(e){var n=[];return n.push("Message: "+e.message),void 0!==e.data&&n.push(" Data: "+JSON.stringify(e.data)),n.join("")},e}(),o=function(){function e(e){this.method=e}return e.prototype.log=function(e){this.method(e)},e}()}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.pnp=n():e.pnp=n()}("undefined"!=typeof self?self:this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(1);t.d(n,"Logger",function(){return r.c}),t.d(n,"ConsoleListener",function(){return r.a}),t.d(n,"FunctionListener",function(){return r.b})},function(e,n,t){"use strict";var r=t(2);t.d(n,"c",function(){return r.a});var o=t(3);t.d(n,"a",function(){return o.a}),t.d(n,"b",function(){return o.b})},function(e,n,t){"use strict";t.d(n,"a",function(){return r});var r=function(){function e(){}return Object.defineProperty(e,"activeLogLevel",{get:function(){return e.instance.activeLogLevel},set:function(n){e.instance.activeLogLevel=n},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return void 0!==e._instance&&null!==e._instance||(e._instance=new o),e._instance},enumerable:!0,configurable:!0}),e.subscribe=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];n.map(function(n){return e.instance.subscribe(n)})},e.clearSubscribers=function(){return e.instance.clearSubscribers()},Object.defineProperty(e,"count",{get:function(){return e.instance.count},enumerable:!0,configurable:!0}),e.write=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:n})},e.writeJSON=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:JSON.stringify(n)})},e.log=function(n){e.instance.log(n)},e.error=function(n){e.instance.log({data:n,level:3,message:n.message})},e}(),o=function(){function e(e,n){void 0===e&&(e=2),void 0===n&&(n=[]),this.activeLogLevel=e,this.subscribers=n}return e.prototype.subscribe=function(e){this.subscribers.push(e)},e.prototype.clearSubscribers=function(){var e=this.subscribers.slice(0);return this.subscribers.length=0,e},Object.defineProperty(e.prototype,"count",{get:function(){return this.subscribers.length},enumerable:!0,configurable:!0}),e.prototype.write=function(e,n){void 0===n&&(n=0),this.log({level:n,message:e})},e.prototype.log=function(e){void 0!==e&&this.activeLogLevel<=e.level&&this.subscribers.map(function(n){return n.log(e)})},e}()},function(e,n,t){"use strict";t.d(n,"a",function(){return r}),t.d(n,"b",function(){return o});var r=function(){function e(){}return e.prototype.log=function(e){var n=this.format(e);switch(e.level){case 0:case 1:console.log(n);break;case 2:console.warn(n);break;case 3:console.error(n)}},e.prototype.format=function(e){var n=[];return n.push("Message: "+e.message),void 0!==e.data&&n.push(" Data: "+JSON.stringify(e.data)),n.join("")},e}(),o=function(){function e(e){this.method=e}return e.prototype.log=function(e){this.method(e)},e}()}])});
//# sourceMappingURL=logging.es5.umd.bundle.min.js.map
/**
@license
* @pnp/logging v1.0.0-beta.11 - pnp - light-weight, subscribable logging framework
* @pnp/logging v1.0.0-rc.0 - pnp - light-weight, subscribable logging framework
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE)

@@ -108,3 +108,3 @@ * Copyright (c) 2018 Microsoft

Logger.error = function (err) {
Logger.instance.log({ data: err, level: 3 /* Error */, message: "[" + err.name + "]::" + err.message });
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
};

@@ -111,0 +111,0 @@ return Logger;

/**
@license
* @pnp/logging v1.0.0-beta.11 - pnp - light-weight, subscribable logging framework
* @pnp/logging v1.0.0-rc.0 - pnp - light-weight, subscribable logging framework
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE)

@@ -10,2 +10,2 @@ * Copyright (c) 2018 Microsoft

*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e.pnp=e.pnp||{},e.pnp.logging={}))}(this,function(e){"use strict";var n=function(){function e(){}return Object.defineProperty(e,"activeLogLevel",{get:function(){return e.instance.activeLogLevel},set:function(n){e.instance.activeLogLevel=n},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return void 0!==e._instance&&null!==e._instance||(e._instance=new t),e._instance},enumerable:!0,configurable:!0}),e.subscribe=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];n.map(function(n){return e.instance.subscribe(n)})},e.clearSubscribers=function(){return e.instance.clearSubscribers()},Object.defineProperty(e,"count",{get:function(){return e.instance.count},enumerable:!0,configurable:!0}),e.write=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:n})},e.writeJSON=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:JSON.stringify(n)})},e.log=function(n){e.instance.log(n)},e.error=function(n){e.instance.log({data:n,level:3,message:"["+n.name+"]::"+n.message})},e}(),t=function(){function e(e,n){void 0===e&&(e=2),void 0===n&&(n=[]),this.activeLogLevel=e,this.subscribers=n}return e.prototype.subscribe=function(e){this.subscribers.push(e)},e.prototype.clearSubscribers=function(){var e=this.subscribers.slice(0);return this.subscribers.length=0,e},Object.defineProperty(e.prototype,"count",{get:function(){return this.subscribers.length},enumerable:!0,configurable:!0}),e.prototype.write=function(e,n){void 0===n&&(n=0),this.log({level:n,message:e})},e.prototype.log=function(e){void 0!==e&&this.activeLogLevel<=e.level&&this.subscribers.map(function(n){return n.log(e)})},e}(),i=function(){function e(){}return e.prototype.log=function(e){var n=this.format(e);switch(e.level){case 0:case 1:console.log(n);break;case 2:console.warn(n);break;case 3:console.error(n)}},e.prototype.format=function(e){var n=[];return n.push("Message: "+e.message),void 0!==e.data&&n.push(" Data: "+JSON.stringify(e.data)),n.join("")},e}(),o=function(){function e(e){this.method=e}return e.prototype.log=function(e){this.method(e)},e}();e.Logger=n,e.ConsoleListener=i,e.FunctionListener=o,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e.pnp=e.pnp||{},e.pnp.logging={}))}(this,function(e){"use strict";var n=function(){function e(){}return Object.defineProperty(e,"activeLogLevel",{get:function(){return e.instance.activeLogLevel},set:function(n){e.instance.activeLogLevel=n},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return void 0!==e._instance&&null!==e._instance||(e._instance=new t),e._instance},enumerable:!0,configurable:!0}),e.subscribe=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];n.map(function(n){return e.instance.subscribe(n)})},e.clearSubscribers=function(){return e.instance.clearSubscribers()},Object.defineProperty(e,"count",{get:function(){return e.instance.count},enumerable:!0,configurable:!0}),e.write=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:n})},e.writeJSON=function(n,t){void 0===t&&(t=0),e.instance.log({level:t,message:JSON.stringify(n)})},e.log=function(n){e.instance.log(n)},e.error=function(n){e.instance.log({data:n,level:3,message:n.message})},e}(),t=function(){function e(e,n){void 0===e&&(e=2),void 0===n&&(n=[]),this.activeLogLevel=e,this.subscribers=n}return e.prototype.subscribe=function(e){this.subscribers.push(e)},e.prototype.clearSubscribers=function(){var e=this.subscribers.slice(0);return this.subscribers.length=0,e},Object.defineProperty(e.prototype,"count",{get:function(){return this.subscribers.length},enumerable:!0,configurable:!0}),e.prototype.write=function(e,n){void 0===n&&(n=0),this.log({level:n,message:e})},e.prototype.log=function(e){void 0!==e&&this.activeLogLevel<=e.level&&this.subscribers.map(function(n){return n.log(e)})},e}(),i=function(){function e(){}return e.prototype.log=function(e){var n=this.format(e);switch(e.level){case 0:case 1:console.log(n);break;case 2:console.warn(n);break;case 3:console.error(n)}},e.prototype.format=function(e){var n=[];return n.push("Message: "+e.message),void 0!==e.data&&n.push(" Data: "+JSON.stringify(e.data)),n.join("")},e}(),o=function(){function e(e){this.method=e}return e.prototype.log=function(e){this.method(e)},e}();e.Logger=n,e.ConsoleListener=i,e.FunctionListener=o,Object.defineProperty(e,"__esModule",{value:!0})});
/**
@license
* @pnp/logging v1.0.0-beta.11 - pnp - light-weight, subscribable logging framework
* @pnp/logging v1.0.0-rc.0 - pnp - light-weight, subscribable logging framework
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE)

@@ -82,3 +82,3 @@ * Copyright (c) 2018 Microsoft

static error(err) {
Logger.instance.log({ data: err, level: 3 /* Error */, message: `[${err.name}]::${err.message}` });
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
}

@@ -85,0 +85,0 @@ }

# @pnp/logging
[![npm version](https://badge.fury.io/js/%40pnp%2Flogging.svg)](https://badge.fury.io/js/%40pnp%2Flogging)
The logging module provides light weight subscribable and extensiable logging framework which is used internally and available for use in your projects. This article outlines how to setup logging and use the various loggers.
### Understanding the Logging Framework
## Getting Started
The logging framework is based on the Logger class to which any number of listeners can be subscribed. Each of these listeners will receive each of the messages logged. And each listener must implement the _LogListener_ interface, shown below. There is only one method to implement and it takes an instance of the LogEntry interface, also shown.
Install the logging module, it has no other dependencies
`npm install @pnp/logging --save`
## Understanding the Logging Framework
The logging framework is based on the Logger class to which any number of listeners can be subscribed. Each of these listeners will receive each of the messages logged. Each listener must implement the _LogListener_ interface, shown below. There is only one method to implement and it takes an instance of the LogEntry interface.
```TypeScript

@@ -43,2 +51,14 @@ /**

### Log Levels
```TypeScript
export const enum LogLevel {
Verbose = 0,
Info = 1,
Warning = 2,
Error = 3,
Off = 99,
}
```
## Writing to the Logger

@@ -49,2 +69,7 @@

```TypeScript
import {
Logger,
LogLevel
} from "@pnp/logging";
// write logs a simple string as the message value of the LogEntry

@@ -73,3 +98,3 @@ Logger.write("This is logging a simple string");

There exists a shortcut method to log an error to the Logger. This will log an entry to the subscribed loggers where the data property will be the Error
instance pased in, the level will be Error, and the message will be a concatenation of the Error instance name and message.
instance pased in, the level will be Error, and the message will be the Error instance message.

@@ -84,3 +109,3 @@ ```TypeScript

By default no listeners are subscribed, so if you would like to get logging information you need to subscribe at least one listener. This is done as shown below by importing the Logger and your listener(s) of choice. Here we are using the provided Console Listener. We are also setting the active log level, which controls the level of logging that will be output. Be aware that Verbose produces a substantial amount of data about each request.
By default no listeners are subscribed, so if you would like to get logging information you need to subscribe at least one listener. This is done as shown below by importing the Logger and your listener(s) of choice. Here we are using the provided ConsoleListener. We are also setting the active log level, which controls the level of logging that will be output. Be aware that Verbose produces a substantial amount of data about each request.

@@ -92,3 +117,3 @@ ```TypeScript

LogLevel
} from "sp-pnp-js";
} from "@pnp/logging";

@@ -108,3 +133,3 @@ // subscribe a listener

This listener outputs information to the console and works in Node as well as within browsers. It takes no settings but does write to the appropriate console method based on message level. For example a LogEntry with level Warning will be written to console.warn. Usage is shown in the example above.
This listener outputs information to the console and works in Node as well as within browsers. It takes no settings and writes to the appropriate console method based on message level. For example a LogEntry with level Warning will be written to console.warn. Usage is shown in the example above.

@@ -120,3 +145,3 @@ ### FunctionListener

LogEntry
} from "sp-pnp-js";
} from "@pnp/logging";

@@ -141,3 +166,3 @@ let listener = new FunctionListener((entry: LogEntry) => {

LogEntry
} from "sp-pnp-js";
} from "@pnp/logging";

@@ -144,0 +169,0 @@ class MyListener implements LogListener {

{
"name": "@pnp/logging",
"version": "1.0.0-beta.11",
"version": "1.0.0-rc.0",
"description": "pnp - light-weight, subscribable logging framework",

@@ -8,3 +8,3 @@ "main": "./dist/logging.es5.umd.js",

"dependencies": {
"tslib": "1.7.1"
"tslib": "1.8.1"
},

@@ -11,0 +11,0 @@ "author": {

![SharePoint Patterns and Practices](https://devofficecdn.azureedge.net/media/Default/PnP/sppnp.png)
The SharePoint Patterns and Practices client side libraries were created to help enable developers to do their best work, without worrying about the exact
REST api details. Built with feedback from the community they represent a way to simplify your day-to-day dev cycle while relying on tested and proven
patterns.
Please use [http://aka.ms/sppnp](http://aka.ms/sppnp) for the latest updates around the whole *SharePoint Patterns and Practices (PnP) initiative*.
## Source & Docs
This code is managed within the [main pnp repo](https://github.com/pnp/pnp), please report issues and submit pull requests there.
Please see the public site for [package documentation](https://pnp.github.io/pnp/).
### Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

@@ -7,0 +18,0 @@

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

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