# @open-age/logger

> context logger that uses watson logger

Latest version **1.4.0** (published 2020-09-17) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install @open-age/logger
pnpm add @open-age/logger
yarn add @open-age/logger
bun add @open-age/logger
```

## 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.4.0 |
| Published | 2020-09-17 |
| First published | 2017-10-19 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sunny Parkash |
| Maintainers | sunny-parkash |
| Keywords | logger, context |

## Links

- npm: https://www.npmjs.com/package/@open-age/logger
- Repository: https://github.com/openage/logger
- Homepage: https://github.com/openage/logger#readme
- Issues: https://github.com/openage/logger/issues
- npm.io page: https://npm.io/package/@open-age/logger

## Dependencies (2)

- [config](https://npm.io/package/config.md) ^3.0.1
- [winston](https://npm.io/package/winston.md) ^2.4.4

## 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.4.0 (latest) — 2020-09-17
- 1.3.6 — 2019-04-21
- 1.3.5 — 2019-04-19
- 1.3.4 — 2019-04-19
- 1.3.3 — 2019-01-24
- 1.2.3 — 2019-01-08
- 1.2.1 — 2019-01-07
- 1.2.0 — 2019-01-07
- 1.1.0 — 2018-04-01
- 1.0.2 — 2017-10-19
- 1.0.1 — 2017-10-19
- 1.0.0 — 2017-10-19

## README

# @open-age/logger

adds context of call along to the logged message

## installation

```shell
npm install @open-age/logger --save
```

## usage

```javascript
var logger = require("@open-age/logger")('processor')
// adds [processor] context to the message that gets logged

let process = function() {
    var logWithLocation = logger.start('process')
    // output [processor:process] started - if logStart is enabled
    log.info('complete');
    // output [processor:process] complete

    // OR

    let context = {
        location: 'process',
        user: {
            code: 'admin'
        }
    }
    var loggerWithContext = logger.start(context)
    // output - if logStart is enabled
    // [processor:process] started
    //
    // output - if custom logger is defined, it adds the full context to meta
    // started
    // {
    //     context: {
    //         location: 'processor:process',
    //         user: {
    //             code: 'admin'
    //         }
    //     }
    // }
    log.info('complete', {
        status: 'done'
    });
    // output - if custom logger is defined, it adds the full context to meta
    // started
    // {
    //     status: 'done',
    //     context: {
    //         location: 'processor:process',
    //         user: {
    //             code: 'admin'
    //         }
    //     }
    // }
}
```

## config

uses `config` package

gets logger section from the config file

```JSON
{
    "logger": {
        "logStart": false, // logs starts of the
        "file": {},
        "console": {},
        "http": {},
        "@open-age/logger-insight": { // logs messages to insight api
            "level": "silly"
        }
}
```

### file

```JSON
"file": {
    "filename": "logs/logs.json",
    "level": "silly",
    "handleExceptions": true,
    "json": true,
    "maxsize": 512000, //0.5
    "maxFiles": 5,
    "colorize": false
}
```

### console

```JSON
"console": {
    "level": "debug",
    "handleExceptions": true,
    "json": false,
    "colorize": true
}
```

### http

```JSON
```

### custom

Push the logs to insight api

Add relevant dependencies in `package.json`

```json
{
    "dependencies": {
        "@open-age/logger-insight": "^1.0.0"
    }
}
```

Declare it logger part of `config.json`

```JSON
{
    "@open-age/logger-insight": {
        "level": "silly"
    }
}
```

Add relevant configs;for insight logger it uses `@open-age/insight-client` which in turn uses `providers.insight.url` to discover the api

```json
{
    "providers" : {
        "insight": {
            "url": "https://dev.openage.in/insight/api"
        }
    }
}
```

Available custom loggers

- @open-age/logger-insight
- @open-age/logger-gcp
- @open-age/logger-aws

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