# @webmotors/wmawslog-js

> Lib to log on AWS SQS

Latest version **1.0.4** (published 2023-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webmotors/wmawslog-js
pnpm add @webmotors/wmawslog-js
yarn add @webmotors/wmawslog-js
bun add @webmotors/wmawslog-js
```

## 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 | 2023-03-23 |
| First published | 2020-11-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rodrigo Alviani |
| Maintainers | rafael-web, silviocontreiras, webmotors.anderson, webmotors.villasboas, consultor5a.luiz, bruno.orcajo, p22.hegedus, infraestrutura, davidcarvalho, laboritbr-dev, rodrigoalviani |

## Links

- npm: https://www.npmjs.com/package/@webmotors/wmawslog-js
- Homepage: https://github.com/webmotors/wmawslog-js
- npm.io page: https://npm.io/package/@webmotors/wmawslog-js

## Recent versions

- 1.0.4 (latest) — 2023-03-23
- 1.0.3 — 2020-12-10
- 1.0.2 — 2020-11-09
- 1.0.1 — 2020-11-09

## README

# wmawslog-js
A simple lib to send logs to AWS SQS from applications.

## How to use
```js
const log = require('@webmotors/wmawslog-js');

exports.handler = async (event, context) => {
    // configure
    log.init({ app: 'lambdaTest', env: 'prd', level: 'warn', queue: 'https://sqs.us-east-1.amazonaws.com/{{account_id}}/{{queue_name}}' });

    await log.info('Function started...');

    try {
     /**
      * code to be logged
      */
    } catch (err) {
        await log.error(err);
    }
};
```

## Log level hierarchy
|       | fatal | error | warn | info | debug | trace |
| ----- | ----- | ----- | ---- | ---- | ----- | ----- |
| fatal |   x   |   x   |  x   |   x  |   x   |   x   |
| error |       |   x   |  x   |   x  |   x   |   x   |
| warn  |       |       |  x   |   x  |   x   |   x   |
| info  |       |       |      |   x  |   x   |   x   |
| debug |       |       |      |      |   x   |   x   |
| trace |       |       |      |      |       |   x   |

### .init()
Required.

| Param | Name             | Description                | Options                                | Default | Required |
| ----- | ---------------- | -------------------------- | -------------------------------------- | ------- | -------- |
| app   | Application Name | Used for group logs        | n/a                                    | n/a     | true     |
| env   | Environment      | Used for group logs        | dev, hml, azl, prd                     | hml     | false    |
| level | Log Level        | Minimun level to be logged | fatal, error, warn, info, debug, trace | warn    | false    |
| queue | Queue url        | AWS SQS Queue url          | n/a                                    | n/a     | true     |

### .fatal(message)
Logs a fatal error.
Message is required (can be a string, object, error stack, etc...);

### .error(message)
Logs a error.
Message is required (can be a string, object, error stack, etc...);

### .warn(message)
Logs a warn.
Message is required (can be a string, object, error stack, etc...);

### .info(message)
Logs a info.
Message is required (can be a string, object, error stack, etc...);

### .debug(message)
Logs a debug.
Message is required (can be a string, object, error stack, etc...);

### .trace(message)
Logs a trace.
Message is required (can be a string, object, error stack, etc...);

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