# @konso/logging

> Client for konso.io logs

Latest version **0.0.5** (published 2022-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @konso/logging
pnpm add @konso/logging
yarn add @konso/logging
bun add @konso/logging
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2022-03-31 |
| First published | 2022-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Daniel Belchenko |
| Maintainers | posokhin_anton_indevlabs, danyadanyadanya, alexlvovich |

## Links

- npm: https://www.npmjs.com/package/@konso/logging
- Repository: https://github.com/konsoio/konso-clients-js.git#release
- Homepage: https://github.com/konsoio/konso-clients-js/tree/release/logging
- Issues: https://github.com/konsoio/konso-clients-js/issues
- npm.io page: https://npm.io/package/@konso/logging

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.0.0

## Recent versions

- 0.0.5 (latest) — 2022-03-31
- 0.0.4 — 2022-03-22
- 0.0.3 — 2022-03-20
- 0.0.1 — 2022-02-01

## README

# Logging

## Installation

---

`npm i @konso/logging`

## Example

---

```javascript
import { createClient, LogEvents } from "@konso/logging";

let client = createClient({
  apiURL: 'https://devapis.konso.io',
  bucketId: '1fc41560',
  apiKey: 'REa9xeOvk6fRxAcNEyebk+5nC5LnbeCr+bJTBpoLm5E=',
  appName: 'test'
})

client.on(LogEvents.onSuccessful, (text) => { console.log(text) })
  .on(LogEvents.onError, (text) => console.error(text));

client.log('message', 'error')
```

## createClient

createClient - the function takes a parameters object and returns an instance of the Logging class

```typescript
const client = createClient({
  apiKey: 'REa9xeOvk6fRxAcNEyebk+5nC5LnbeCr+bJTBpoLm5E=',
  apiURL: 'https://devapis.konso.io',
  bucketId: '1fc41560',
  appName: 'test'
})
```

| Parameter   | Type   | Required |
|:------------|--------|:---------|
| apiKey      | string | true     |
| apiURL      | string | true     |
| bucketId    | string | true     |
| machineName | string | false    |
| env         | string | false    |
| appName     | string | false    |

## Methods

---

## on

```typescript
on(eventName: LogEvents, callback: (text: string) => void);
```

### Parameters

| Parameter | Type     | Required | Value                                                |
|-----------|----------|----------|------------------------------------------------------|
| eventName | string   | true     | 'onSuccessful', 'onError' or keys of LogEvent object |
| callback  | function | true     | (text: string) => void                               |

## log

```typescript
log(message: MessageTypes, logLevel?: LogLevel | MessageTypes, extraOptions?: ExtraOptions): PromiseLike<void>;
```

### Parameters

| Parameter    | Type                                         | Default | Required | Value                                        |
|--------------|----------------------------------------------|---------|----------|----------------------------------------------|
| message      | string, number, Array<string>, Object, Error |         | true     |                                              |
| logLevel     | string, number, Array<string>, Object, Error |         | false    |                                              |
| extraOptions | Object                                       |         | false    | { eventId?: string, correlationId?: string } |

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