decorator-log
v1.0.4
Published
Simple `@Log` decorator made with [kaop](https://github.com/k1r0s/kaop-ts) API:
Downloads
8
Readme
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