# autologger

> small automatic log utility

Latest version **1.0.0** (published 2018-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install autologger
pnpm add autologger
yarn add autologger
bun add autologger
```

## 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.0 |
| Published | 2018-03-10 |
| First published | 2018-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Uskov Anton |
| Maintainers | uskov-anton |
| Keywords | auto, autolog, auto-log, automatic, console, debug, log, logging, logger |

## Links

- npm: https://www.npmjs.com/package/autologger
- Repository: https://github.com/uskov-anton/autologger
- Homepage: https://github.com/uskov-anton/autologger#readme
- Issues: https://github.com/uskov-anton/autologger/issues
- npm.io page: https://npm.io/package/autologger

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-03-10
- 0.2.0 — 2018-02-24
- 0.1.0 — 2018-02-24

## README

# autologger

Javascript utility for automatic logging of functions and classes.

## Install

```bash
$ npm install autologger --save
```

## Usage

```js
const Autolog = require('autologger');

const autolog = Autolog(options)(type)(logger);

let target = autolog(target);
```

|Variable|Type|Required|
|--------|----|--------|
|options|object|no|
|type|string|yes|
|logger|object|yes|
|target|function or class|yes|

### options

Logs the wrapping of a variable by an automatic logger. Must contain two properties:

|Properties|Type|Required|
|----------|----|--------|
|preprocess|function|no|
|postprocess|function|no|

### type

The type of the variable to which automatic logging is applied. One of the following values:
- class
- function
- method

### logger

Logs the call steps. Must contain two properties:

|Properties|Type|Required|
|----------|----|--------|
|before|function|yes|
|after|function|yes|

### target

The function or class to which automatic logging will be applied.

## Example

### Logger

```js
const logger = {
    before: console.log,
    after: console.log,
};
```

### Function

```js
const autolog = Autolog()('function')(logger);

let example = autolog(function example() { /* ... */ });
```

### Class

```js
const autolog = Autolog()('class')(logger);

let Example = autolog(class Example {
    /* ... */
});
```

#### with decorators
> [see js decorators](https://github.com/wycats/javascript-decorators)

```js
const autolog = Autolog()('class')(logger);

@autolog
class Example {
    /* ... */
}
```

### Class method

```js
const autolog = Autolog()('method')(logger);

class Example {
    @autolog
    test() { /* ... */ }
}
```

## License

This project is licensed under [MIT](LICENSE).

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