@lad-tech/nsc-toolkit 1.13.1 → 1.14.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/CHANGELOG.md +3 -3
- package/dist/Service.js +12 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.14.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.13.1...v1.14.0) (2023-08-15)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* debug logs for sync methods ([#70](https://github.com/lad-tech/nsc-toolkit/issues/70)) ([30a3b5a](https://github.com/lad-tech/nsc-toolkit/commit/30a3b5afc66bb79f99b67bac56075cf308ae41ef))
|
package/dist/Service.js
CHANGED
|
@@ -167,11 +167,6 @@ class Service extends Root_1.Root {
|
|
|
167
167
|
dependences[key] = new Proxy(instance, trap);
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
|
-
dependences['logger'] = new toolbelt_1.Logs.Logger({
|
|
171
|
-
location: `${this.serviceName}.${method.settings.action}`,
|
|
172
|
-
metadata: baggage,
|
|
173
|
-
outputFormatter: this.options.loggerOutputFormatter,
|
|
174
|
-
});
|
|
175
170
|
return dependences;
|
|
176
171
|
}
|
|
177
172
|
/**
|
|
@@ -183,7 +178,6 @@ class Service extends Root_1.Root {
|
|
|
183
178
|
for (const key in dependencies) {
|
|
184
179
|
context[key] = dependencies[key];
|
|
185
180
|
}
|
|
186
|
-
context['emitter'] = this.emitter;
|
|
187
181
|
return context;
|
|
188
182
|
}
|
|
189
183
|
/**
|
|
@@ -333,17 +327,27 @@ class Service extends Root_1.Root {
|
|
|
333
327
|
const tracer = api_1.trace.getTracer('');
|
|
334
328
|
const context = this.getContext(baggage);
|
|
335
329
|
const span = tracer.startSpan(subject, undefined, context);
|
|
330
|
+
const logger = new toolbelt_1.Logs.Logger({
|
|
331
|
+
location: `${this.serviceName}.${Method.settings.action}`,
|
|
332
|
+
metadata: baggage,
|
|
333
|
+
outputFormatter: this.options.loggerOutputFormatter,
|
|
334
|
+
});
|
|
336
335
|
try {
|
|
337
336
|
const requestedDependencies = this.createObjectWithDependencies(Method, tracer, this.getNextBaggage(span, baggage));
|
|
338
337
|
const context = this.createMethodContext(Method, requestedDependencies);
|
|
338
|
+
context['logger'] = logger;
|
|
339
|
+
context['emitter'] = this.emitter;
|
|
340
|
+
const response = await context.handler.call(context, payload);
|
|
339
341
|
const result = {
|
|
340
|
-
payload:
|
|
342
|
+
payload: response,
|
|
341
343
|
};
|
|
344
|
+
logger.debug({ request: payload, response });
|
|
342
345
|
this.finishSpan(span);
|
|
343
346
|
return result;
|
|
344
347
|
}
|
|
345
348
|
catch (error) {
|
|
346
|
-
|
|
349
|
+
logger.debug({ request: payload });
|
|
350
|
+
logger.error(error);
|
|
347
351
|
this.finishSpan(span, error);
|
|
348
352
|
return this.buildErrorMessage(error);
|
|
349
353
|
}
|