@pnp/logging 2.10.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -25
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/listeners.d.ts +39 -39
- package/listeners.js +73 -73
- package/logger.d.ts +93 -93
- package/logger.js +141 -141
- package/package.json +1 -1
- package/readme.md +21 -21
package/LICENSE
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
SharePoint Patterns and Practices (PnP)
|
|
2
|
-
|
|
3
|
-
The MIT License (MIT)
|
|
4
|
-
|
|
5
|
-
Copyright (c) Microsoft Corporation
|
|
6
|
-
|
|
7
|
-
All rights reserved.
|
|
8
|
-
|
|
9
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
in the Software without restriction, including without limitation the rights
|
|
12
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
furnished to do so, subject to the following conditions:
|
|
15
|
-
|
|
16
|
-
The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
copies or substantial portions of the Software.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
SOFTWARE.
|
|
1
|
+
SharePoint Patterns and Practices (PnP)
|
|
2
|
+
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) Microsoft Corporation
|
|
6
|
+
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./logger.js";
|
|
2
|
-
export * from "./listeners.js";
|
|
1
|
+
export * from "./logger.js";
|
|
2
|
+
export * from "./listeners.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./logger.js";
|
|
2
|
-
export * from "./listeners.js";
|
|
1
|
+
export * from "./logger.js";
|
|
2
|
+
export * from "./listeners.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/listeners.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { ILogEntry, ILogListener } from "./logger.js";
|
|
2
|
-
/**
|
|
3
|
-
* Implementation of LogListener which logs to the console
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export declare class ConsoleListener implements ILogListener {
|
|
7
|
-
/**
|
|
8
|
-
* Any associated data that a given logging listener may choose to log or ignore
|
|
9
|
-
*
|
|
10
|
-
* @param entry The information to be logged
|
|
11
|
-
*/
|
|
12
|
-
log(entry: ILogEntry): void;
|
|
13
|
-
/**
|
|
14
|
-
* Formats the message
|
|
15
|
-
*
|
|
16
|
-
* @param entry The information to format into a string
|
|
17
|
-
*/
|
|
18
|
-
private format;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Implementation of LogListener which logs to the supplied function
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
export declare class FunctionListener implements ILogListener {
|
|
25
|
-
private method;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new instance of the FunctionListener class
|
|
28
|
-
*
|
|
29
|
-
* @constructor
|
|
30
|
-
* @param method The method to which any logging data will be passed
|
|
31
|
-
*/
|
|
32
|
-
constructor(method: (entry: ILogEntry) => void);
|
|
33
|
-
/**
|
|
34
|
-
* Any associated data that a given logging listener may choose to log or ignore
|
|
35
|
-
*
|
|
36
|
-
* @param entry The information to be logged
|
|
37
|
-
*/
|
|
38
|
-
log(entry: ILogEntry): void;
|
|
39
|
-
}
|
|
1
|
+
import { ILogEntry, ILogListener } from "./logger.js";
|
|
2
|
+
/**
|
|
3
|
+
* Implementation of LogListener which logs to the console
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConsoleListener implements ILogListener {
|
|
7
|
+
/**
|
|
8
|
+
* Any associated data that a given logging listener may choose to log or ignore
|
|
9
|
+
*
|
|
10
|
+
* @param entry The information to be logged
|
|
11
|
+
*/
|
|
12
|
+
log(entry: ILogEntry): void;
|
|
13
|
+
/**
|
|
14
|
+
* Formats the message
|
|
15
|
+
*
|
|
16
|
+
* @param entry The information to format into a string
|
|
17
|
+
*/
|
|
18
|
+
private format;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Implementation of LogListener which logs to the supplied function
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export declare class FunctionListener implements ILogListener {
|
|
25
|
+
private method;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new instance of the FunctionListener class
|
|
28
|
+
*
|
|
29
|
+
* @constructor
|
|
30
|
+
* @param method The method to which any logging data will be passed
|
|
31
|
+
*/
|
|
32
|
+
constructor(method: (entry: ILogEntry) => void);
|
|
33
|
+
/**
|
|
34
|
+
* Any associated data that a given logging listener may choose to log or ignore
|
|
35
|
+
*
|
|
36
|
+
* @param entry The information to be logged
|
|
37
|
+
*/
|
|
38
|
+
log(entry: ILogEntry): void;
|
|
39
|
+
}
|
|
40
40
|
//# sourceMappingURL=listeners.d.ts.map
|
package/listeners.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implementation of LogListener which logs to the console
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
var ConsoleListener = /** @class */ (function () {
|
|
6
|
-
function ConsoleListener() {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Any associated data that a given logging listener may choose to log or ignore
|
|
10
|
-
*
|
|
11
|
-
* @param entry The information to be logged
|
|
12
|
-
*/
|
|
13
|
-
ConsoleListener.prototype.log = function (entry) {
|
|
14
|
-
var msg = this.format(entry);
|
|
15
|
-
switch (entry.level) {
|
|
16
|
-
case 0 /* Verbose */:
|
|
17
|
-
case 1 /* Info */:
|
|
18
|
-
console.log(msg);
|
|
19
|
-
break;
|
|
20
|
-
case 2 /* Warning */:
|
|
21
|
-
console.warn(msg);
|
|
22
|
-
break;
|
|
23
|
-
case 3 /* Error */:
|
|
24
|
-
console.error(msg);
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Formats the message
|
|
30
|
-
*
|
|
31
|
-
* @param entry The information to format into a string
|
|
32
|
-
*/
|
|
33
|
-
ConsoleListener.prototype.format = function (entry) {
|
|
34
|
-
var msg = [];
|
|
35
|
-
msg.push("Message: " + entry.message);
|
|
36
|
-
if (entry.data !== undefined) {
|
|
37
|
-
try {
|
|
38
|
-
msg.push(" Data: " + JSON.stringify(entry.data));
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
msg.push(" Data: Error in stringify of supplied data " + e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return msg.join("");
|
|
45
|
-
};
|
|
46
|
-
return ConsoleListener;
|
|
47
|
-
}());
|
|
48
|
-
export { ConsoleListener };
|
|
49
|
-
/**
|
|
50
|
-
* Implementation of LogListener which logs to the supplied function
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
var FunctionListener = /** @class */ (function () {
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new instance of the FunctionListener class
|
|
56
|
-
*
|
|
57
|
-
* @constructor
|
|
58
|
-
* @param method The method to which any logging data will be passed
|
|
59
|
-
*/
|
|
60
|
-
function FunctionListener(method) {
|
|
61
|
-
this.method = method;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Any associated data that a given logging listener may choose to log or ignore
|
|
65
|
-
*
|
|
66
|
-
* @param entry The information to be logged
|
|
67
|
-
*/
|
|
68
|
-
FunctionListener.prototype.log = function (entry) {
|
|
69
|
-
this.method(entry);
|
|
70
|
-
};
|
|
71
|
-
return FunctionListener;
|
|
72
|
-
}());
|
|
73
|
-
export { FunctionListener };
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of LogListener which logs to the console
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
var ConsoleListener = /** @class */ (function () {
|
|
6
|
+
function ConsoleListener() {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Any associated data that a given logging listener may choose to log or ignore
|
|
10
|
+
*
|
|
11
|
+
* @param entry The information to be logged
|
|
12
|
+
*/
|
|
13
|
+
ConsoleListener.prototype.log = function (entry) {
|
|
14
|
+
var msg = this.format(entry);
|
|
15
|
+
switch (entry.level) {
|
|
16
|
+
case 0 /* Verbose */:
|
|
17
|
+
case 1 /* Info */:
|
|
18
|
+
console.log(msg);
|
|
19
|
+
break;
|
|
20
|
+
case 2 /* Warning */:
|
|
21
|
+
console.warn(msg);
|
|
22
|
+
break;
|
|
23
|
+
case 3 /* Error */:
|
|
24
|
+
console.error(msg);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Formats the message
|
|
30
|
+
*
|
|
31
|
+
* @param entry The information to format into a string
|
|
32
|
+
*/
|
|
33
|
+
ConsoleListener.prototype.format = function (entry) {
|
|
34
|
+
var msg = [];
|
|
35
|
+
msg.push("Message: " + entry.message);
|
|
36
|
+
if (entry.data !== undefined) {
|
|
37
|
+
try {
|
|
38
|
+
msg.push(" Data: " + JSON.stringify(entry.data));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
msg.push(" Data: Error in stringify of supplied data " + e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return msg.join("");
|
|
45
|
+
};
|
|
46
|
+
return ConsoleListener;
|
|
47
|
+
}());
|
|
48
|
+
export { ConsoleListener };
|
|
49
|
+
/**
|
|
50
|
+
* Implementation of LogListener which logs to the supplied function
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
var FunctionListener = /** @class */ (function () {
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new instance of the FunctionListener class
|
|
56
|
+
*
|
|
57
|
+
* @constructor
|
|
58
|
+
* @param method The method to which any logging data will be passed
|
|
59
|
+
*/
|
|
60
|
+
function FunctionListener(method) {
|
|
61
|
+
this.method = method;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Any associated data that a given logging listener may choose to log or ignore
|
|
65
|
+
*
|
|
66
|
+
* @param entry The information to be logged
|
|
67
|
+
*/
|
|
68
|
+
FunctionListener.prototype.log = function (entry) {
|
|
69
|
+
this.method(entry);
|
|
70
|
+
};
|
|
71
|
+
return FunctionListener;
|
|
72
|
+
}());
|
|
73
|
+
export { FunctionListener };
|
|
74
74
|
//# sourceMappingURL=listeners.js.map
|
package/logger.d.ts
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class used to subscribe ILogListener and log messages throughout an application
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export declare class Logger {
|
|
6
|
-
private static _instance;
|
|
7
|
-
/**
|
|
8
|
-
* Gets or sets the active log level to apply for log filtering
|
|
9
|
-
*/
|
|
10
|
-
static get activeLogLevel(): LogLevel;
|
|
11
|
-
static set activeLogLevel(value: LogLevel);
|
|
12
|
-
private static get instance();
|
|
13
|
-
/**
|
|
14
|
-
* Adds ILogListener instances to the set of subscribed listeners
|
|
15
|
-
*
|
|
16
|
-
* @param listeners One or more listeners to subscribe to this log
|
|
17
|
-
*/
|
|
18
|
-
static subscribe(...listeners: ILogListener[]): void;
|
|
19
|
-
/**
|
|
20
|
-
* Clears the subscribers collection, returning the collection before modification
|
|
21
|
-
*/
|
|
22
|
-
static clearSubscribers(): ILogListener[];
|
|
23
|
-
/**
|
|
24
|
-
* Gets the current subscriber count
|
|
25
|
-
*/
|
|
26
|
-
static get count(): number;
|
|
27
|
-
/**
|
|
28
|
-
* Writes the supplied string to the subscribed listeners
|
|
29
|
-
*
|
|
30
|
-
* @param message The message to write
|
|
31
|
-
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
32
|
-
*/
|
|
33
|
-
static write(message: string, level?: LogLevel): void;
|
|
34
|
-
/**
|
|
35
|
-
* Writes the supplied string to the subscribed listeners
|
|
36
|
-
*
|
|
37
|
-
* @param json The json object to stringify and write
|
|
38
|
-
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
39
|
-
*/
|
|
40
|
-
static writeJSON(json: any, level?: LogLevel): void;
|
|
41
|
-
/**
|
|
42
|
-
* Logs the supplied entry to the subscribed listeners
|
|
43
|
-
*
|
|
44
|
-
* @param entry The message to log
|
|
45
|
-
*/
|
|
46
|
-
static log(entry: ILogEntry): void;
|
|
47
|
-
/**
|
|
48
|
-
* Logs an error object to the subscribed listeners
|
|
49
|
-
*
|
|
50
|
-
* @param err The error object
|
|
51
|
-
*/
|
|
52
|
-
static error(err: Error): void;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A set of logging levels
|
|
56
|
-
*/
|
|
57
|
-
export declare const enum LogLevel {
|
|
58
|
-
Verbose = 0,
|
|
59
|
-
Info = 1,
|
|
60
|
-
Warning = 2,
|
|
61
|
-
Error = 3,
|
|
62
|
-
Off = 99
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Interface that defines a log entry
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
export interface ILogEntry {
|
|
69
|
-
/**
|
|
70
|
-
* The main message to be logged
|
|
71
|
-
*/
|
|
72
|
-
message: string;
|
|
73
|
-
/**
|
|
74
|
-
* The level of information this message represents
|
|
75
|
-
*/
|
|
76
|
-
level: LogLevel;
|
|
77
|
-
/**
|
|
78
|
-
* Any associated data that a given logging listener may choose to log or ignore
|
|
79
|
-
*/
|
|
80
|
-
data?: any;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Interface that defines a log listener
|
|
84
|
-
*
|
|
85
|
-
*/
|
|
86
|
-
export interface ILogListener {
|
|
87
|
-
/**
|
|
88
|
-
* Any associated data that a given logging listener may choose to log or ignore
|
|
89
|
-
*
|
|
90
|
-
* @param entry The information to be logged
|
|
91
|
-
*/
|
|
92
|
-
log(entry: ILogEntry): void;
|
|
93
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Class used to subscribe ILogListener and log messages throughout an application
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export declare class Logger {
|
|
6
|
+
private static _instance;
|
|
7
|
+
/**
|
|
8
|
+
* Gets or sets the active log level to apply for log filtering
|
|
9
|
+
*/
|
|
10
|
+
static get activeLogLevel(): LogLevel;
|
|
11
|
+
static set activeLogLevel(value: LogLevel);
|
|
12
|
+
private static get instance();
|
|
13
|
+
/**
|
|
14
|
+
* Adds ILogListener instances to the set of subscribed listeners
|
|
15
|
+
*
|
|
16
|
+
* @param listeners One or more listeners to subscribe to this log
|
|
17
|
+
*/
|
|
18
|
+
static subscribe(...listeners: ILogListener[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Clears the subscribers collection, returning the collection before modification
|
|
21
|
+
*/
|
|
22
|
+
static clearSubscribers(): ILogListener[];
|
|
23
|
+
/**
|
|
24
|
+
* Gets the current subscriber count
|
|
25
|
+
*/
|
|
26
|
+
static get count(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Writes the supplied string to the subscribed listeners
|
|
29
|
+
*
|
|
30
|
+
* @param message The message to write
|
|
31
|
+
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
32
|
+
*/
|
|
33
|
+
static write(message: string, level?: LogLevel): void;
|
|
34
|
+
/**
|
|
35
|
+
* Writes the supplied string to the subscribed listeners
|
|
36
|
+
*
|
|
37
|
+
* @param json The json object to stringify and write
|
|
38
|
+
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
39
|
+
*/
|
|
40
|
+
static writeJSON(json: any, level?: LogLevel): void;
|
|
41
|
+
/**
|
|
42
|
+
* Logs the supplied entry to the subscribed listeners
|
|
43
|
+
*
|
|
44
|
+
* @param entry The message to log
|
|
45
|
+
*/
|
|
46
|
+
static log(entry: ILogEntry): void;
|
|
47
|
+
/**
|
|
48
|
+
* Logs an error object to the subscribed listeners
|
|
49
|
+
*
|
|
50
|
+
* @param err The error object
|
|
51
|
+
*/
|
|
52
|
+
static error(err: Error): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A set of logging levels
|
|
56
|
+
*/
|
|
57
|
+
export declare const enum LogLevel {
|
|
58
|
+
Verbose = 0,
|
|
59
|
+
Info = 1,
|
|
60
|
+
Warning = 2,
|
|
61
|
+
Error = 3,
|
|
62
|
+
Off = 99
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Interface that defines a log entry
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
export interface ILogEntry {
|
|
69
|
+
/**
|
|
70
|
+
* The main message to be logged
|
|
71
|
+
*/
|
|
72
|
+
message: string;
|
|
73
|
+
/**
|
|
74
|
+
* The level of information this message represents
|
|
75
|
+
*/
|
|
76
|
+
level: LogLevel;
|
|
77
|
+
/**
|
|
78
|
+
* Any associated data that a given logging listener may choose to log or ignore
|
|
79
|
+
*/
|
|
80
|
+
data?: any;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Interface that defines a log listener
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
export interface ILogListener {
|
|
87
|
+
/**
|
|
88
|
+
* Any associated data that a given logging listener may choose to log or ignore
|
|
89
|
+
*
|
|
90
|
+
* @param entry The information to be logged
|
|
91
|
+
*/
|
|
92
|
+
log(entry: ILogEntry): void;
|
|
93
|
+
}
|
|
94
94
|
//# sourceMappingURL=logger.d.ts.map
|
package/logger.js
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class used to subscribe ILogListener and log messages throughout an application
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
var Logger = /** @class */ (function () {
|
|
6
|
-
function Logger() {
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(Logger, "activeLogLevel", {
|
|
9
|
-
/**
|
|
10
|
-
* Gets or sets the active log level to apply for log filtering
|
|
11
|
-
*/
|
|
12
|
-
get: function () {
|
|
13
|
-
return Logger.instance.activeLogLevel;
|
|
14
|
-
},
|
|
15
|
-
set: function (value) {
|
|
16
|
-
Logger.instance.activeLogLevel = value;
|
|
17
|
-
},
|
|
18
|
-
enumerable: false,
|
|
19
|
-
configurable: true
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(Logger, "instance", {
|
|
22
|
-
get: function () {
|
|
23
|
-
if (Logger._instance === undefined || Logger._instance === null) {
|
|
24
|
-
Logger._instance = new LoggerImpl();
|
|
25
|
-
}
|
|
26
|
-
return Logger._instance;
|
|
27
|
-
},
|
|
28
|
-
enumerable: false,
|
|
29
|
-
configurable: true
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Adds ILogListener instances to the set of subscribed listeners
|
|
33
|
-
*
|
|
34
|
-
* @param listeners One or more listeners to subscribe to this log
|
|
35
|
-
*/
|
|
36
|
-
Logger.subscribe = function () {
|
|
37
|
-
var listeners = [];
|
|
38
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
39
|
-
listeners[_i] = arguments[_i];
|
|
40
|
-
}
|
|
41
|
-
listeners.forEach(function (listener) { return Logger.instance.subscribe(listener); });
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Clears the subscribers collection, returning the collection before modification
|
|
45
|
-
*/
|
|
46
|
-
Logger.clearSubscribers = function () {
|
|
47
|
-
return Logger.instance.clearSubscribers();
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(Logger, "count", {
|
|
50
|
-
/**
|
|
51
|
-
* Gets the current subscriber count
|
|
52
|
-
*/
|
|
53
|
-
get: function () {
|
|
54
|
-
return Logger.instance.count;
|
|
55
|
-
},
|
|
56
|
-
enumerable: false,
|
|
57
|
-
configurable: true
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Writes the supplied string to the subscribed listeners
|
|
61
|
-
*
|
|
62
|
-
* @param message The message to write
|
|
63
|
-
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
64
|
-
*/
|
|
65
|
-
Logger.write = function (message, level) {
|
|
66
|
-
if (level === void 0) { level = 1 /* Info */; }
|
|
67
|
-
Logger.instance.log({ level: level, message: message });
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Writes the supplied string to the subscribed listeners
|
|
71
|
-
*
|
|
72
|
-
* @param json The json object to stringify and write
|
|
73
|
-
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
74
|
-
*/
|
|
75
|
-
Logger.writeJSON = function (json, level) {
|
|
76
|
-
if (level === void 0) { level = 1 /* Info */; }
|
|
77
|
-
this.write(JSON.stringify(json), level);
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Logs the supplied entry to the subscribed listeners
|
|
81
|
-
*
|
|
82
|
-
* @param entry The message to log
|
|
83
|
-
*/
|
|
84
|
-
Logger.log = function (entry) {
|
|
85
|
-
Logger.instance.log(entry);
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Logs an error object to the subscribed listeners
|
|
89
|
-
*
|
|
90
|
-
* @param err The error object
|
|
91
|
-
*/
|
|
92
|
-
Logger.error = function (err) {
|
|
93
|
-
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
|
|
94
|
-
};
|
|
95
|
-
return Logger;
|
|
96
|
-
}());
|
|
97
|
-
export { Logger };
|
|
98
|
-
var LoggerImpl = /** @class */ (function () {
|
|
99
|
-
function LoggerImpl(activeLogLevel, subscribers) {
|
|
100
|
-
if (activeLogLevel === void 0) { activeLogLevel = 2 /* Warning */; }
|
|
101
|
-
if (subscribers === void 0) { subscribers = []; }
|
|
102
|
-
this.activeLogLevel = activeLogLevel;
|
|
103
|
-
this.subscribers = subscribers;
|
|
104
|
-
}
|
|
105
|
-
LoggerImpl.prototype.subscribe = function (listener) {
|
|
106
|
-
this.subscribers.push(listener);
|
|
107
|
-
};
|
|
108
|
-
LoggerImpl.prototype.clearSubscribers = function () {
|
|
109
|
-
var s = this.subscribers.slice(0);
|
|
110
|
-
this.subscribers.length = 0;
|
|
111
|
-
return s;
|
|
112
|
-
};
|
|
113
|
-
Object.defineProperty(LoggerImpl.prototype, "count", {
|
|
114
|
-
get: function () {
|
|
115
|
-
return this.subscribers.length;
|
|
116
|
-
},
|
|
117
|
-
enumerable: false,
|
|
118
|
-
configurable: true
|
|
119
|
-
});
|
|
120
|
-
LoggerImpl.prototype.write = function (message, level) {
|
|
121
|
-
if (level === void 0) { level = 1 /* Info */; }
|
|
122
|
-
this.log({ level: level, message: message });
|
|
123
|
-
};
|
|
124
|
-
LoggerImpl.prototype.log = function (entry) {
|
|
125
|
-
if (entry !== undefined && this.activeLogLevel <= entry.level) {
|
|
126
|
-
this.subscribers.map(function (subscriber) { return subscriber.log(entry); });
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
return LoggerImpl;
|
|
130
|
-
}());
|
|
131
|
-
/**
|
|
132
|
-
* A set of logging levels
|
|
133
|
-
*/
|
|
134
|
-
export var LogLevel;
|
|
135
|
-
(function (LogLevel) {
|
|
136
|
-
LogLevel[LogLevel["Verbose"] = 0] = "Verbose";
|
|
137
|
-
LogLevel[LogLevel["Info"] = 1] = "Info";
|
|
138
|
-
LogLevel[LogLevel["Warning"] = 2] = "Warning";
|
|
139
|
-
LogLevel[LogLevel["Error"] = 3] = "Error";
|
|
140
|
-
LogLevel[LogLevel["Off"] = 99] = "Off";
|
|
141
|
-
})(LogLevel || (LogLevel = {}));
|
|
1
|
+
/**
|
|
2
|
+
* Class used to subscribe ILogListener and log messages throughout an application
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
var Logger = /** @class */ (function () {
|
|
6
|
+
function Logger() {
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(Logger, "activeLogLevel", {
|
|
9
|
+
/**
|
|
10
|
+
* Gets or sets the active log level to apply for log filtering
|
|
11
|
+
*/
|
|
12
|
+
get: function () {
|
|
13
|
+
return Logger.instance.activeLogLevel;
|
|
14
|
+
},
|
|
15
|
+
set: function (value) {
|
|
16
|
+
Logger.instance.activeLogLevel = value;
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(Logger, "instance", {
|
|
22
|
+
get: function () {
|
|
23
|
+
if (Logger._instance === undefined || Logger._instance === null) {
|
|
24
|
+
Logger._instance = new LoggerImpl();
|
|
25
|
+
}
|
|
26
|
+
return Logger._instance;
|
|
27
|
+
},
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Adds ILogListener instances to the set of subscribed listeners
|
|
33
|
+
*
|
|
34
|
+
* @param listeners One or more listeners to subscribe to this log
|
|
35
|
+
*/
|
|
36
|
+
Logger.subscribe = function () {
|
|
37
|
+
var listeners = [];
|
|
38
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
39
|
+
listeners[_i] = arguments[_i];
|
|
40
|
+
}
|
|
41
|
+
listeners.forEach(function (listener) { return Logger.instance.subscribe(listener); });
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Clears the subscribers collection, returning the collection before modification
|
|
45
|
+
*/
|
|
46
|
+
Logger.clearSubscribers = function () {
|
|
47
|
+
return Logger.instance.clearSubscribers();
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(Logger, "count", {
|
|
50
|
+
/**
|
|
51
|
+
* Gets the current subscriber count
|
|
52
|
+
*/
|
|
53
|
+
get: function () {
|
|
54
|
+
return Logger.instance.count;
|
|
55
|
+
},
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Writes the supplied string to the subscribed listeners
|
|
61
|
+
*
|
|
62
|
+
* @param message The message to write
|
|
63
|
+
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
64
|
+
*/
|
|
65
|
+
Logger.write = function (message, level) {
|
|
66
|
+
if (level === void 0) { level = 1 /* Info */; }
|
|
67
|
+
Logger.instance.log({ level: level, message: message });
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Writes the supplied string to the subscribed listeners
|
|
71
|
+
*
|
|
72
|
+
* @param json The json object to stringify and write
|
|
73
|
+
* @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
|
|
74
|
+
*/
|
|
75
|
+
Logger.writeJSON = function (json, level) {
|
|
76
|
+
if (level === void 0) { level = 1 /* Info */; }
|
|
77
|
+
this.write(JSON.stringify(json), level);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Logs the supplied entry to the subscribed listeners
|
|
81
|
+
*
|
|
82
|
+
* @param entry The message to log
|
|
83
|
+
*/
|
|
84
|
+
Logger.log = function (entry) {
|
|
85
|
+
Logger.instance.log(entry);
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Logs an error object to the subscribed listeners
|
|
89
|
+
*
|
|
90
|
+
* @param err The error object
|
|
91
|
+
*/
|
|
92
|
+
Logger.error = function (err) {
|
|
93
|
+
Logger.instance.log({ data: err, level: 3 /* Error */, message: err.message });
|
|
94
|
+
};
|
|
95
|
+
return Logger;
|
|
96
|
+
}());
|
|
97
|
+
export { Logger };
|
|
98
|
+
var LoggerImpl = /** @class */ (function () {
|
|
99
|
+
function LoggerImpl(activeLogLevel, subscribers) {
|
|
100
|
+
if (activeLogLevel === void 0) { activeLogLevel = 2 /* Warning */; }
|
|
101
|
+
if (subscribers === void 0) { subscribers = []; }
|
|
102
|
+
this.activeLogLevel = activeLogLevel;
|
|
103
|
+
this.subscribers = subscribers;
|
|
104
|
+
}
|
|
105
|
+
LoggerImpl.prototype.subscribe = function (listener) {
|
|
106
|
+
this.subscribers.push(listener);
|
|
107
|
+
};
|
|
108
|
+
LoggerImpl.prototype.clearSubscribers = function () {
|
|
109
|
+
var s = this.subscribers.slice(0);
|
|
110
|
+
this.subscribers.length = 0;
|
|
111
|
+
return s;
|
|
112
|
+
};
|
|
113
|
+
Object.defineProperty(LoggerImpl.prototype, "count", {
|
|
114
|
+
get: function () {
|
|
115
|
+
return this.subscribers.length;
|
|
116
|
+
},
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true
|
|
119
|
+
});
|
|
120
|
+
LoggerImpl.prototype.write = function (message, level) {
|
|
121
|
+
if (level === void 0) { level = 1 /* Info */; }
|
|
122
|
+
this.log({ level: level, message: message });
|
|
123
|
+
};
|
|
124
|
+
LoggerImpl.prototype.log = function (entry) {
|
|
125
|
+
if (entry !== undefined && this.activeLogLevel <= entry.level) {
|
|
126
|
+
this.subscribers.map(function (subscriber) { return subscriber.log(entry); });
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return LoggerImpl;
|
|
130
|
+
}());
|
|
131
|
+
/**
|
|
132
|
+
* A set of logging levels
|
|
133
|
+
*/
|
|
134
|
+
export var LogLevel;
|
|
135
|
+
(function (LogLevel) {
|
|
136
|
+
LogLevel[LogLevel["Verbose"] = 0] = "Verbose";
|
|
137
|
+
LogLevel[LogLevel["Info"] = 1] = "Info";
|
|
138
|
+
LogLevel[LogLevel["Warning"] = 2] = "Warning";
|
|
139
|
+
LogLevel[LogLevel["Error"] = 3] = "Error";
|
|
140
|
+
LogLevel[LogLevel["Off"] = 99] = "Off";
|
|
141
|
+
})(LogLevel || (LogLevel = {}));
|
|
142
142
|
//# sourceMappingURL=logger.js.map
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
The SharePoint Patterns and Practices client side libraries were created to help enable developers to do their best work, without worrying about the exact
|
|
4
|
-
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
|
|
5
|
-
patterns.
|
|
6
|
-
|
|
7
|
-
Please use [http://aka.ms/sppnp](http://aka.ms/sppnp) for the latest updates around the whole *SharePoint Patterns and Practices (PnP) initiative*.
|
|
8
|
-
|
|
9
|
-
## Source & Docs
|
|
10
|
-
|
|
11
|
-
This code is managed within the [main pnp repo](https://github.com/pnp/pnp), please report issues and submit pull requests there.
|
|
12
|
-
|
|
13
|
-
Please see the public site for [package documentation](https://pnp.github.io/pnpjs/).
|
|
14
|
-
|
|
15
|
-
### Code of Conduct
|
|
16
|
-
|
|
17
|
-
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.
|
|
18
|
-
|
|
19
|
-
### "Sharing is Caring"
|
|
20
|
-
|
|
21
|
-
### Disclaimer
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
The SharePoint Patterns and Practices client side libraries were created to help enable developers to do their best work, without worrying about the exact
|
|
4
|
+
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
|
|
5
|
+
patterns.
|
|
6
|
+
|
|
7
|
+
Please use [http://aka.ms/sppnp](http://aka.ms/sppnp) for the latest updates around the whole *SharePoint Patterns and Practices (PnP) initiative*.
|
|
8
|
+
|
|
9
|
+
## Source & Docs
|
|
10
|
+
|
|
11
|
+
This code is managed within the [main pnp repo](https://github.com/pnp/pnp), please report issues and submit pull requests there.
|
|
12
|
+
|
|
13
|
+
Please see the public site for [package documentation](https://pnp.github.io/pnpjs/).
|
|
14
|
+
|
|
15
|
+
### Code of Conduct
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
### "Sharing is Caring"
|
|
20
|
+
|
|
21
|
+
### Disclaimer
|
|
22
22
|
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|