Browse Source

Fixes log decorator on getters

main
Eric Amodio 5 years ago
parent
commit
5462b7d652
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      src/system/decorators/log.ts

+ 6
- 3
src/system/decorators/log.ts View File

@ -86,18 +86,21 @@ export function log any>(
| typeof Logger.debug
| typeof Logger.log;
return (target: any, key: string, descriptor: PropertyDescriptor) => {
return (target: any, key: string, descriptor: PropertyDescriptor & { [key: string]: any }) => {
let fn: Function | undefined;
let fnKey: string | undefined;
if (typeof descriptor.value === 'function') {
fn = descriptor.value;
fnKey = 'value';
} else if (typeof descriptor.get === 'function') {
fn = descriptor.get;
fnKey = 'get';
}
if (fn == null) throw new Error('Not supported');
if (fn == null || fnKey == null) throw new Error('Not supported');
const parameters = Functions.getParameters(fn);
descriptor.value = function(this: any, ...args: Parameters<T>) {
descriptor[fnKey] = function(this: any, ...args: Parameters<T>) {
const correlationId = getNextCorrelationId();
if (

Loading…
Cancel
Save