1.0.4 • Published 7 years ago

decorator-log v1.0.4

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

Simple @Log decorator made with kaop API:

import { afterMethod } from "kaop-ts";

export const Log = afterMethod(function(meta){
  const methodName = `${meta.target.constructor.name}::${meta.propertyKey}`;
  console.info(`log-decorator: ${methodName} invoked!`);
  console.info(`log-decorator: ${methodName} arguments -> `, meta.args);
  console.info(`log-decorator: ${methodName} result -> `, meta.result);
});

Usage:

npm install decorator-log

Import:

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { CommonRequest } from './common-request.service';
import { Observable } from 'rxjs/Observable';
import { Post } from '../models/post';
import { Log } from 'decorator-log'; // <<-- HERE

@Injectable()
export class PostRepository extends CommonRequest {
  constructor(http: Http) {
    super(http, 'posts');
  }

  @Log // <<-- HERE
  public getResource(userId: string): Promise<Post[]> {
    const path = `?userId=${userId}`;
    return super.getResource(path);
  }
}

Sample output

example output

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago