@transcommerce/cwm-shared 1.1.33 → 1.1.34
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.
|
@@ -27085,45 +27085,99 @@ const MockCustomer = {
|
|
|
27085
27085
|
"subscriptionId": "1"
|
|
27086
27086
|
};
|
|
27087
27087
|
|
|
27088
|
+
/*
|
|
27089
|
+
* A simple generic LIFO stack.
|
|
27090
|
+
*
|
|
27091
|
+
* Example:
|
|
27092
|
+
* ```ts
|
|
27093
|
+
* const s = new Stack<number>();
|
|
27094
|
+
* s.push(1);
|
|
27095
|
+
* s.push(2);
|
|
27096
|
+
* console.log(s.pop());
|
|
27097
|
+
* @typeParam T - Type of items stored in the stack.
|
|
27098
|
+
*/
|
|
27099
|
+
class Stack {
|
|
27100
|
+
items = [];
|
|
27101
|
+
/*
|
|
27102
|
+
Pushes an item onto the top of the stack.
|
|
27103
|
+
@param item - Item to push.
|
|
27104
|
+
*/
|
|
27105
|
+
push(item) { this.items.push(item); }
|
|
27106
|
+
/*
|
|
27107
|
+
Removes and returns the item at the top of the stack.
|
|
27108
|
+
@returns The popped item, or undefined if the stack is empty.
|
|
27109
|
+
*/
|
|
27110
|
+
pop() { return this.items.pop(); }
|
|
27111
|
+
/*
|
|
27112
|
+
Returns the item at the top without removing it.
|
|
27113
|
+
@returns The top item, or undefined if the stack is empty.
|
|
27114
|
+
*/
|
|
27115
|
+
peek() { return this.items[this.items.length - 1]; }
|
|
27116
|
+
/*
|
|
27117
|
+
Number of items currently in the stack.
|
|
27118
|
+
*/
|
|
27119
|
+
get size() { return this.items.length; }
|
|
27120
|
+
/*
|
|
27121
|
+
Returns a string representation of all items currently in the stack.
|
|
27122
|
+
*/
|
|
27123
|
+
toString() { return this.items.toString(); }
|
|
27124
|
+
}
|
|
27125
|
+
|
|
27088
27126
|
/*
|
|
27089
27127
|
The LogService is really just a wrapper around the existing console logging functionality
|
|
27090
27128
|
The three main reasons for using this service are:
|
|
27091
|
-
1. The abstraction layer will allow us to pick a different logging
|
|
27129
|
+
1. The abstraction layer will allow us to pick a different logging endpoint if needed
|
|
27092
27130
|
2. This service allows you to specify what level verbosity you want this service tp log with
|
|
27093
27131
|
3. Has logic to log method entry and exit points automagically
|
|
27094
|
-
|
|
27132
|
+
4. Keeps track of call stack for nested method calls
|
|
27133
|
+
02*/
|
|
27095
27134
|
class LogService {
|
|
27096
27135
|
logLevel = 'Info';
|
|
27097
|
-
|
|
27098
|
-
get className() {
|
|
27136
|
+
_classStack = new Stack();
|
|
27137
|
+
get className() {
|
|
27138
|
+
return this._classStack.peek() ?? "";
|
|
27139
|
+
}
|
|
27099
27140
|
set className(value) {
|
|
27100
|
-
if (this.
|
|
27101
|
-
|
|
27141
|
+
if (this.logLevel === 'None') {
|
|
27142
|
+
return;
|
|
27143
|
+
}
|
|
27144
|
+
if (this._classStack.size > 0 && this._classStack.peek() !== value) {
|
|
27145
|
+
//console.groupCollapsed(this.targetName + " - " + value + " - " + new Date().toLocaleString())
|
|
27146
|
+
console.groupEnd();
|
|
27147
|
+
this._classStack.pop();
|
|
27102
27148
|
}
|
|
27103
|
-
if (this.
|
|
27104
|
-
this.
|
|
27149
|
+
if (this._classStack.size === 0 || this._classStack.peek() !== value) {
|
|
27150
|
+
this._classStack.push(value);
|
|
27105
27151
|
this.methodName = "constructor()";
|
|
27106
27152
|
}
|
|
27107
27153
|
else {
|
|
27108
|
-
this.
|
|
27154
|
+
this._classStack.push(value);
|
|
27109
27155
|
}
|
|
27110
27156
|
}
|
|
27111
|
-
|
|
27112
|
-
get methodName() {
|
|
27157
|
+
_methodStack = new Stack();
|
|
27158
|
+
get methodName() {
|
|
27159
|
+
return this._methodStack.peek() ?? "";
|
|
27160
|
+
}
|
|
27113
27161
|
set methodName(value) {
|
|
27114
|
-
if (
|
|
27115
|
-
|
|
27116
|
-
console.groupEnd();
|
|
27117
|
-
console.timeEnd(this.targetName);
|
|
27118
|
-
this._methodName = value;
|
|
27162
|
+
if (this.logLevel === 'None') {
|
|
27163
|
+
return;
|
|
27119
27164
|
}
|
|
27120
|
-
|
|
27121
|
-
this.
|
|
27165
|
+
if (value === "") {
|
|
27166
|
+
this.endOfMethod();
|
|
27167
|
+
}
|
|
27168
|
+
else {
|
|
27169
|
+
this._methodStack.push(value);
|
|
27122
27170
|
console.group(this.targetName);
|
|
27123
27171
|
console.time(this.targetName);
|
|
27124
27172
|
this.info("Start of method");
|
|
27125
27173
|
}
|
|
27126
27174
|
}
|
|
27175
|
+
endOfMethod() {
|
|
27176
|
+
this.info("End of method");
|
|
27177
|
+
console.groupEnd();
|
|
27178
|
+
console.timeEnd(this.targetName);
|
|
27179
|
+
this._methodStack.pop();
|
|
27180
|
+
}
|
|
27127
27181
|
get targetName() {
|
|
27128
27182
|
if (this.methodName === "")
|
|
27129
27183
|
return this.className;
|
|
@@ -27135,45 +27189,27 @@ class LogService {
|
|
|
27135
27189
|
}
|
|
27136
27190
|
log(message, ...optionalParams) {
|
|
27137
27191
|
if (this.logLevel != 'None') {
|
|
27138
|
-
|
|
27139
|
-
console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
|
|
27140
|
-
else
|
|
27141
|
-
console.log(this.prefix + " " + message, optionalParams);
|
|
27192
|
+
console.log(this.prefix + " " + message, optionalParams);
|
|
27142
27193
|
}
|
|
27143
27194
|
}
|
|
27144
27195
|
debug(message, ...optionalParams) {
|
|
27145
27196
|
if (this.logLevel === 'Debug') {
|
|
27146
|
-
|
|
27147
|
-
console.timeEnd(this.targetName);
|
|
27148
|
-
console.time(this.targetName);
|
|
27149
|
-
}
|
|
27150
|
-
console.debug(this.prefix + " " + message, optionalParams);
|
|
27197
|
+
console.debug(this.prefix + " Debug: " + message, optionalParams);
|
|
27151
27198
|
}
|
|
27152
27199
|
}
|
|
27153
27200
|
info(message, ...optionalParams) {
|
|
27154
27201
|
if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27155
|
-
|
|
27156
|
-
console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
|
|
27157
|
-
else
|
|
27158
|
-
console.info(this.prefix + " " + message, optionalParams);
|
|
27202
|
+
console.info(this.prefix + " Information: " + message, optionalParams);
|
|
27159
27203
|
}
|
|
27160
27204
|
}
|
|
27161
27205
|
warn(message, ...optionalParams) {
|
|
27162
27206
|
if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27163
|
-
|
|
27164
|
-
console.timeEnd(this.targetName);
|
|
27165
|
-
console.time(this.targetName);
|
|
27166
|
-
}
|
|
27167
|
-
console.warn(this.prefix + " " + message, optionalParams);
|
|
27207
|
+
console.warn(this.prefix + " Warning: " + message, optionalParams);
|
|
27168
27208
|
}
|
|
27169
27209
|
}
|
|
27170
27210
|
error(message, ...optionalParams) {
|
|
27171
27211
|
if (this.logLevel != 'None') {
|
|
27172
|
-
|
|
27173
|
-
console.timeEnd(this.targetName);
|
|
27174
|
-
console.time(this.targetName);
|
|
27175
|
-
}
|
|
27176
|
-
console.error(this.prefix + " " + message, optionalParams);
|
|
27212
|
+
console.error(this.prefix + " Error: " + message, optionalParams);
|
|
27177
27213
|
}
|
|
27178
27214
|
}
|
|
27179
27215
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|