You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Boilerplate-free decorator-based class logging. Log method calls and creation of your class easily with the help of two decorators. No prototype mutation. Highly configurable. Built with TypeScript. Works with Node.js and in browser.
4
4
@@ -72,7 +72,7 @@ Logs `Test.method1 -> done. Args: []. Res: 123.` after it.
72
72
73
73
## Requirements
74
74
75
-
Your evnvironment must support [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). For Node.js it's [6.4.0+](https://node.green/), for browsers it's [Edge 12+, Firefox 18+, Chrome 49+, Safari 10+](https://caniuse.com/#search=proxy).
75
+
Your environment must support [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). For Node.js it's [6.4.0+](https://node.green/), for browsers it's [Edge 12+, Firefox 18+, Chrome 49+, Safari 10+](https://caniuse.com/#search=proxy).
@@ -278,9 +278,9 @@ It enables/disabled including the formatted class instance to your log messages.
278
278
- Why? It's a rare case when your prototype changes dynamically, therefore it hardly makes any sense to log it.
279
279
- Drop any of them that have `function` type.
280
280
- Why? Most of the time `function` properties are just immutable arrow functions used instead of regular class methods to preserve `this` context. It doesn't make much sense to bloat your logs with stringified bodies of those functions.
281
-
-Drop any of them that are not plain objects.
281
+
-Transform any of them that are not plain objects recursively.
282
282
- What objects are plain ones? `ClassLoggerFormatterService` considers an object a plain object if its prototype is strictly equal to `Object.prototype`.
283
-
- Why? Often we include instances of other classes as properties (inject them as dependencies). Our logs would become extremely fat if we included stringified versions of these dependencies.
283
+
- Why? Often we include instances of other classes as properties (inject them as dependencies). By stringifying them using the same algorithm we can see what we injected.
284
284
- Stringify what's left.
285
285
286
286
Example:
@@ -306,14 +306,14 @@ class Test {
306
306
}
307
307
308
308
// Logs to the console before the class' construction:
309
-
// 'Test.construct. Args: []. Class instance: {"prop1":42,"prop2":{"test":42}}.'
309
+
// 'Test.construct. Args: []. Class instance: {"serviceA": ServiceA {},"prop1":42,"prop2":{"test":42}}.'
310
310
const test =newTest()
311
311
312
312
// Logs to the console before the method call:
313
-
// 'Test.method2. Args: []. Class instance: {"prop1":42,"prop2":{"test":42}}.'
313
+
// 'Test.method2. Args: []. Class instance: {"serviceA": ServiceA {},"prop1":42,"prop2":{"test":42}}.'
0 commit comments