Skip to content

Commit 4d1a8c4

Browse files
committed
chore: fix comments
1 parent 09adbb9 commit 4d1a8c4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/common/decorators.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function performanceLog(injector?: IInjector): any {
9595
const performanceService: IPerformanceService = injector.resolve("performanceService");
9696

9797
//needed for the returned function to have the same name as the original - used in hooks decorator
98-
const tempObject = {
98+
const functionWrapper = {
9999
[originalMethod.name]: function (...args: Array<any>) {
100100
const start = performanceService.now();
101101
const result = originalMethod.apply(this, args);
@@ -120,7 +120,7 @@ export function performanceLog(injector?: IInjector): any {
120120
return result;
121121
}
122122
};
123-
descriptor.value = tempObject[originalMethod.name];
123+
descriptor.value = functionWrapper[originalMethod.name];
124124

125125
// used to get parameter names in hooks decorator
126126
descriptor.value.toString = () => {

lib/services/performance-service.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as semver from "semver";
55

66
export class PerformanceService implements IPerformanceService {
77
public static LOG_MESSAGE_TEMPLATE = `Execution of method "%s" took %s ms.`;
8-
public static FAIL_LOG_MESSAGE_TEMPLATE = `Failed to log pefromance data for method %s.`;
8+
public static FAIL_LOG_MESSAGE_TEMPLATE = `Failed to log pefromance data in file for method %s.`;
99
private static MIN_NODE_PERFORMANCE_MODULE_VERSION = "8.5.0";
1010
private performance: {now(): number} = null;
1111

@@ -59,7 +59,7 @@ export class PerformanceService implements IPerformanceService {
5959
let methodArgs;
6060

6161
try {
62-
methodArgs = JSON.stringify(args, this.getCircularReplacer());
62+
methodArgs = JSON.stringify(args, this.getJsonSanitizer());
6363
} catch (e) {
6464
methodArgs = "cyclic args";
6565
}
@@ -75,10 +75,12 @@ export class PerformanceService implements IPerformanceService {
7575
this.$fs.appendFile(filePath, `${JSON.stringify(info)}${EOL}`);
7676
} catch (e) {
7777
this.$logger.trace(PerformanceService.FAIL_LOG_MESSAGE_TEMPLATE, methodInfo);
78+
this.$logger.info(PerformanceService.LOG_MESSAGE_TEMPLATE, methodInfo, executionTime);
7879
}
7980
}
8081

81-
private getCircularReplacer() {
82+
//removes any injected members of the arguments and excludes the options object even if it was renamed
83+
private getJsonSanitizer() {
8284
const seen = new WeakSet();
8385
seen.add(this.$options);
8486
return (key: any, value: any) => {

0 commit comments

Comments
 (0)