Skip to content

Commit

Permalink
docs: adds usage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
madoos committed Aug 23, 2018
1 parent b86268d commit a9cf6e4
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ Centralizes the tracking of logs in a single point.

- [Motivation](#motivation)
- [Install](#install)
- [Usage](#usage)
- [Features](#features)
- [How does it work](#how-does-it-work)
- [Configuration](#configuration-options)
- [Log structure](#log-structure)

## Motivation

Normally when we have to get logs to report the status of the applications we have to mess up many functions adding code logs.
Normally when we have to get logs to report the application status we have to mess up many functions adding code logs.

That makes it more difficult to test and change the dependency of the logger because we have to look for it manually in all the code.
That makes it more difficult to test and change the logger dependency because we have to look for it manually in all the code.

```javascript
// in user.js
Expand Down Expand Up @@ -113,6 +114,36 @@ To install:

npm i -S decogger

## Usage

In logger.config.js

```javascript
module.exports = {
logger: console.log,
logErrors: true,
modules: [
{
module: require("./src/user"),
tag: "src.user",
time: true,
oi: true
}
]
}
```

In the entry point

```javascript
const decogger = require("decogger")
const config = require("./logger.config")
decogger(config)

const user = require("./src/user")
// ...
```

## Features

- [Define a global logger](#define-a-global-logger)
Expand All @@ -125,7 +156,9 @@ To install:

## How does it work

- If the module is a function the function is doctorate with the log configuration
- Must to be the first module required in main file
- For asynchronous functions WORKS ONLY WITH PROMISES
- If the module is a function, the function is decorate with log configuration
- If the module is an object(POJOs) or class instance all properties that are functions are decorated
- If the module is a constructor function all the static methods and all the props that are functions in each instance are decorated
- if the module is a primitive data type it does not do anything
Expand Down

0 comments on commit a9cf6e4

Please sign in to comment.