@anglr/common 17.0.0-beta.20230709184222 → 17.0.0-beta.20230710045229

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.
@@ -56,23 +56,23 @@ class DeveloperConsoleSinkService {
56
56
  case LogEventLevel.error:
57
57
  case LogEventLevel.fatal:
58
58
  {
59
- console.log(fullMessage, 'color: #FF3131;');
59
+ this._writeLog(fullMessage, 'FF3131');
60
60
  break;
61
61
  }
62
62
  case LogEventLevel.verbose:
63
63
  case LogEventLevel.debug:
64
64
  {
65
- console.log(fullMessage, 'color: #31A1FF;');
65
+ this._writeLog(fullMessage, '31A1FF');
66
66
  break;
67
67
  }
68
68
  case LogEventLevel.information:
69
69
  {
70
- console.log(fullMessage, 'color: #ffffff;');
70
+ this._writeLog(fullMessage, 'ffffff');
71
71
  break;
72
72
  }
73
73
  case LogEventLevel.warning:
74
74
  {
75
- console.log(fullMessage, 'color: #FFC531;');
75
+ this._writeLog(fullMessage, 'FFC531');
76
76
  break;
77
77
  }
78
78
  }
@@ -94,6 +94,24 @@ class DeveloperConsoleSinkService {
94
94
  messageTemplateInstance.constructor.prototype.toText = toText;
95
95
  }
96
96
  }
97
+ /**
98
+ * Writes message to log
99
+ * @param fullMessage - Full message to be written
100
+ * @param color - Color of message
101
+ */
102
+ _writeLog(fullMessage, color) {
103
+ const index = fullMessage.indexOf('\n');
104
+ if (index >= 0) {
105
+ const firstLine = fullMessage.slice(0, index);
106
+ const restLines = fullMessage.slice(index + 1);
107
+ console.groupCollapsed(firstLine, `color: #${color};`);
108
+ console.log(restLines, `color: #${color};`);
109
+ console.groupEnd();
110
+ }
111
+ else {
112
+ console.log(fullMessage, `color: #${color};`);
113
+ }
114
+ }
97
115
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: DeveloperConsoleSinkService, deps: [{ token: i1.DeveloperConsoleSinkOptions, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
98
116
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: DeveloperConsoleSinkService });
99
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"developerConsoleSink.service.js","sourceRoot":"","sources":["../../../../../structured-log/src/services/developerConsole/developerConsoleSink.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAiB,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;;;AAE3E;;GAEG;AACH,MACa,2BAA2B;IAEpC,oEAAoE;IAEpE;;OAEG;IACK,iBAAiB,GAAY,KAAK,CAAC;IAE3C;;OAEG;IACK,OAAO,CAA8B;IAE7C,iEAAiE;IACjE,YAAwB,MAAoC;QAExD,IAAG,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,YAAY,2BAA2B,CAAC,EAC9D;YACI,IAAI,CAAC,OAAO,GAAG,IAAI,2BAA2B,EAAE,CAAC;SACpD;aAED;YACI,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;IACL,CAAC;IAED,6FAA6F;IAE7F;;;OAGG;IACI,IAAI,CAAC,MAAkB;QAE1B,IAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAC5B;YACI,OAAO;SACV;QAED,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAEf,IAAG,CAAC,IAAI,CAAC,iBAAiB,EAC1B;gBACI,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;gBAEzB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;aACjC;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC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C,WAAW,IAAI,uBAAuB,CAAC,WAAW,CAAC,SAAS,IAAI,uBAAuB,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAC/I;YACI,uBAAuB,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC;SACjE;IACL,CAAC;uGArHQ,2BAA2B;2GAA3B,2BAA2B;;SAA3B,2BAA2B;2FAA3B,2BAA2B;kBADvC,UAAU;;0BAgBM,QAAQ","sourcesContent":["import {Injectable, Optional} from '@angular/core';\nimport {Sink, LogEvent, LogEventLevel} from 'structured-log';\n\nimport {toText, isEnabled} from '../../misc/utils';\nimport {DeveloperConsoleSinkOptions} from './developerConsoleSink.options';\n\n/**\n * Sink that is used for storing logs using browser developer console\n */\n@Injectable()\nexport class DeveloperConsoleSinkService implements Sink\n{\n //######################### private fields #########################\n\n /**\n * Indication that prototype of MessageTemplate was updated\n */\n private _prototypeUpdated: boolean = false;\n\n /**\n * Options for this sink\n */\n private _config: DeveloperConsoleSinkOptions;\n\n //######################### constructor #########################\n constructor(@Optional() config?: DeveloperConsoleSinkOptions,)\n {\n if(!config || !(config instanceof DeveloperConsoleSinkOptions))\n {\n this._config = new DeveloperConsoleSinkOptions();\n }\n else\n {\n this._config = config;\n }\n }\n\n //######################### public methods - implementation of Sink #########################\n\n /**\n * Emits events into log\n * @param events - Events to be emitted\n */\n public emit(events: LogEvent[]): void\n {\n if(!events || !events.length)\n {\n return;\n }\n\n events.forEach(e =>\n {\n if(!this._prototypeUpdated)\n {\n this._updatePrototype(e);\n\n this._prototypeUpdated = true;\n }\n\n if (!isEnabled(this._config.restrictToLevel, e.level))\n {\n return;\n }\n\n const logLevel = LogEventLevel[e.level].toUpperCase();\n const timestamp = e.timestamp;\n const message = e.messageTemplate.render(e.properties);\n const fullMessage = `%cLOGGER: ${logLevel} - ${timestamp}: ${message}`;\n\n switch(e.level)\n {\n default:\n case LogEventLevel.off:\n {\n break;\n }\n case LogEventLevel.error:\n case LogEventLevel.fatal:\n {\n console.log(fullMessage, 'color: #FF3131;');\n\n break;\n }\n case LogEventLevel.verbose:\n case LogEventLevel.debug:\n {\n console.log(fullMessage, 'color: #31A1FF;');\n\n break;\n }\n case LogEventLevel.information:\n {\n console.log(fullMessage, 'color: #ffffff;');\n\n break;\n }\n case LogEventLevel.warning:\n {\n console.log(fullMessage, 'color: #FFC531;');\n\n break;\n }\n }\n });\n }\n\n /**\n * Flushes logs\n */\n public flush(): Promise<void>\n {\n return Promise.resolve();\n }\n\n //######################### private methods #########################\n\n /**\n * Updates prototype of MessageTemplate\n */\n private _updatePrototype(e: LogEvent): void\n {\n const messageTemplateInstance = (<any>e.messageTemplate);\n\n if(messageTemplateInstance.constructor && messageTemplateInstance.constructor.prototype && messageTemplateInstance.constructor.prototype.toText)\n {\n messageTemplateInstance.constructor.prototype.toText = toText;\n }\n }\n}"]}
1
+ {"version":3,"file":"developerConsoleSink.service.js","sourceRoot":"","sources":["../../../../../structured-log/src/services/developerConsole/developerConsoleSink.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAiB,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;;;AAE3E;;GAEG;AACH,MACa,2BAA2B;IAEpC,oEAAoE;IAEpE;;OAEG;IACK,iBAAiB,GAAY,KAAK,CAAC;IAE3C;;OAEG;IACK,OAAO,CAA8B;IAE7C,iEAAiE;IACjE,YAAwB,MAAoC;QAExD,IAAG,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,YAAY,2BAA2B,CAAC,EAC9D;YACI,IAAI,CAAC,OAAO,GAAG,IAAI,2BAA2B,EAAE,CAAC;SACpD;aAED;YACI,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;IACL,CAAC;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B,2BAA2B;2FAA3B,2BAA2B;kBADvC,UAAU;;0BAgBM,QAAQ","sourcesContent":["import {Injectable, Optional} from '@angular/core';\nimport {Sink, LogEvent, LogEventLevel} from 'structured-log';\n\nimport {toText, isEnabled} from '../../misc/utils';\nimport {DeveloperConsoleSinkOptions} from './developerConsoleSink.options';\n\n/**\n * Sink that is used for storing logs using browser developer console\n */\n@Injectable()\nexport class DeveloperConsoleSinkService implements Sink\n{\n //######################### private fields #########################\n\n /**\n * Indication that prototype of MessageTemplate was updated\n */\n private _prototypeUpdated: boolean = false;\n\n /**\n * Options for this sink\n */\n private _config: DeveloperConsoleSinkOptions;\n\n //######################### constructor #########################\n constructor(@Optional() config?: DeveloperConsoleSinkOptions,)\n {\n if(!config || !(config instanceof DeveloperConsoleSinkOptions))\n {\n this._config = new DeveloperConsoleSinkOptions();\n }\n else\n {\n this._config = config;\n }\n }\n\n //######################### public methods - implementation of Sink #########################\n\n /**\n * Emits events into log\n * @param events - Events to be emitted\n */\n public emit(events: LogEvent[]): void\n {\n if(!events || !events.length)\n {\n return;\n }\n\n events.forEach(e =>\n {\n if(!this._prototypeUpdated)\n {\n this._updatePrototype(e);\n\n this._prototypeUpdated = true;\n }\n\n if (!isEnabled(this._config.restrictToLevel, e.level))\n {\n return;\n }\n\n const logLevel = LogEventLevel[e.level].toUpperCase();\n const timestamp = e.timestamp;\n const message = e.messageTemplate.render(e.properties);\n const fullMessage = `%cLOGGER: ${logLevel} - ${timestamp}: ${message}`;\n\n switch(e.level)\n {\n default:\n case LogEventLevel.off:\n {\n break;\n }\n case LogEventLevel.error:\n case LogEventLevel.fatal:\n {\n this._writeLog(fullMessage, 'FF3131');\n\n break;\n }\n case LogEventLevel.verbose:\n case LogEventLevel.debug:\n {\n this._writeLog(fullMessage, '31A1FF');\n\n break;\n }\n case LogEventLevel.information:\n {\n this._writeLog(fullMessage, 'ffffff');\n\n break;\n }\n case LogEventLevel.warning:\n {\n this._writeLog(fullMessage, 'FFC531');\n\n break;\n }\n }\n });\n }\n\n /**\n * Flushes logs\n */\n public flush(): Promise<void>\n {\n return Promise.resolve();\n }\n\n //######################### private methods #########################\n\n /**\n * Updates prototype of MessageTemplate\n */\n private _updatePrototype(e: LogEvent): void\n {\n const messageTemplateInstance = (<any>e.messageTemplate);\n\n if(messageTemplateInstance.constructor && messageTemplateInstance.constructor.prototype && messageTemplateInstance.constructor.prototype.toText)\n {\n messageTemplateInstance.constructor.prototype.toText = toText;\n }\n }\n\n /**\n * Writes message to log\n * @param fullMessage - Full message to be written\n * @param color - Color of message\n */\n private _writeLog(fullMessage: string, color: string): void\n {\n const index = fullMessage.indexOf('\\n');\n\n if(index >= 0)\n {\n const firstLine = fullMessage.slice(0, index);\n const restLines = fullMessage.slice(index + 1);\n\n console.groupCollapsed(firstLine, `color: #${color};`);\n console.log(restLines, `color: #${color};`);\n console.groupEnd();\n }\n else\n {\n console.log(fullMessage, `color: #${color};`);\n }\n }\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anglr/common",
3
- "version": "17.0.0-beta.20230709184222",
3
+ "version": "17.0.0-beta.20230710045229",
4
4
  "description": "Angular module for common angular stuff",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -27,6 +27,12 @@ export declare class DeveloperConsoleSinkService implements Sink {
27
27
  * Updates prototype of MessageTemplate
28
28
  */
29
29
  private _updatePrototype;
30
+ /**
31
+ * Writes message to log
32
+ * @param fullMessage - Full message to be written
33
+ * @param color - Color of message
34
+ */
35
+ private _writeLog;
30
36
  static ɵfac: i0.ɵɵFactoryDeclaration<DeveloperConsoleSinkService, [{ optional: true; }]>;
31
37
  static ɵprov: i0.ɵɵInjectableDeclaration<DeveloperConsoleSinkService>;
32
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"developerConsoleSink.service.d.ts","sourceRoot":"","sources":["developerConsoleSink.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;;AAE3E;;GAEG;AACH,qBACa,2BAA4B,YAAW,IAAI;IAIpD;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAAkB;IAE3C;;OAEG;IACH,OAAO,CAAC,OAAO,CAA8B;gBAGrB,MAAM,CAAC,EAAE,2BAA2B;IAc5D;;;OAGG;IACI,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI;IA+DrC;;OAEG;IACI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;yCA7Gf,2BAA2B;6CAA3B,2BAA2B;CAsHvC"}
1
+ {"version":3,"file":"developerConsoleSink.service.d.ts","sourceRoot":"","sources":["developerConsoleSink.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;;AAE3E;;GAEG;AACH,qBACa,2BAA4B,YAAW,IAAI;IAIpD;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAAkB;IAE3C;;OAEG;IACH,OAAO,CAAC,OAAO,CAA8B;gBAGrB,MAAM,CAAC,EAAE,2BAA2B;IAc5D;;;OAGG;IACI,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI;IA+DrC;;OAEG;IACI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;;;OAIG;IACH,OAAO,CAAC,SAAS;yCA5HR,2BAA2B;6CAA3B,2BAA2B;CA8IvC"}
package/version.bak CHANGED
@@ -1 +1 @@
1
- 17.0.0-beta.20230709184222
1
+ 17.0.0-beta.20230710045229