# decorator-log

> Simple `@Log` decorator made with [kaop](https://github.com/k1r0s/kaop-ts) API:

Latest version **1.0.4** (published 2017-09-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install decorator-log
pnpm add decorator-log
yarn add decorator-log
bun add decorator-log
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-09-16 |
| First published | 2017-09-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | k1r0s |

## Links

- npm: https://www.npmjs.com/package/decorator-log
- npm.io page: https://npm.io/package/decorator-log

## Dependencies (1)

- [kaop-ts](https://npm.io/package/kaop-ts.md) ^1.5.0

## Recent versions

- 1.0.4 (latest) — 2017-09-16
- 1.0.3 — 2017-09-16
- 1.0.2 — 2017-09-16
- 1.0.1 — 2017-09-16
- 1.0.0 — 2017-09-16

## README

Simple `@Log` decorator made with [kaop](https://github.com/k1r0s/kaop-ts) API:

```javascript
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:

```javascript
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](http://en.zimagez.com/full/d2c5c68a694dee48187bb987ec28cd541344ee91c8e3c62a6924c0fb25bf0a9d76b93ac22bd119282ca0db6da479130a5e80c930dabe7cb0.php)

---
_Source: https://npm.io/package/decorator-log · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
