Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uskov-anton/autologger
small automatic log utility
https://github.com/uskov-anton/autologger
auto autolog autologger autologs automatic console debug log logger logging
Last synced: about 2 months ago
JSON representation
small automatic log utility
- Host: GitHub
- URL: https://github.com/uskov-anton/autologger
- Owner: uskov-anton
- License: mit
- Created: 2018-02-24T14:34:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-10T19:10:28.000Z (almost 7 years ago)
- Last Synced: 2024-10-31T18:59:01.787Z (2 months ago)
- Topics: auto, autolog, autologger, autologs, automatic, console, debug, log, logger, logging
- Language: JavaScript
- Homepage:
- Size: 132 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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).