# loglight

> Quickly and easily NodeJS module for save and report any logs.

Latest version **1.1.2** (published 2021-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install loglight
pnpm add loglight
yarn add loglight
bun add loglight
```

## 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.1.2 |
| Published | 2021-09-07 |
| First published | 2021-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 19.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Fosper |
| Maintainers | fosper |
| Keywords | log, logger, stacktrace, debug, handle, debugger, handler |

## Links

- npm: https://www.npmjs.com/package/loglight
- Repository: https://github.com/fosper/loglight
- Homepage: https://github.com/fosper/loglight#readme
- Issues: https://github.com/fosper/loglight/issues
- npm.io page: https://npm.io/package/loglight

## Dependencies (2)

- [tgmlight](https://npm.io/package/tgmlight.md) ^1.0.7
- [toolslight](https://npm.io/package/toolslight.md) ^2.0.0

## 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.1.2 (latest) — 2021-09-07
- 1.1.1 — 2021-08-25
- 1.1.0 — 2021-08-22
- 1.0.4 — 2021-08-13
- 1.0.3 — 2021-08-13
- 1.0.2 — 2021-07-16
- 1.0.1 — 2021-07-15
- 1.0.0 — 2021-07-05

## README

# loglight
Quickly and easily NodeJS module for save and report any logs.

## Installation
```bash
$ npm i loglight
```

## Quick Start
    1. Create 'log' and 'logTg' in project directory for just for test.
    2. Create test.js in project directory.
    3. Copy code below, paste to test.js, save. Run test.js

```js
const loglight = require('loglight')

let logger = new loglight({
    reportPhrases: ['global test phrase'], // Required: no (optional).
    reportHeader: 'My header for all sources.' // Required: no (optional).
})

logger.setUTC(-3) // Required: no (optional).

logger.addSource('console', {
    name: 'myConsole1', // Required: no (optional).
    reportPhrases: ['console test phrase'], // Required: no (optional).
    reportHeader: 'Custom header for console source.' // Required: no (optional).
})

logger.addSource('file', {
    name: 'myFileSource1', // Required: no (optional).
    reportPhrases: ['file test phrase'], // Required: no (optional).
    reportHeader: 'Custom header for file source.', // Required: no (optional).
    directory: __dirname + '/log' // Required: yes. Path must have existing directory for save log files in this directory.
})

logger.addSource('telegram', {
    name: 'myTelegramSource1', // Required: no (optional).
    reportPhrases: ['telegram test phrase'], // Required: no (optional).
    reportHeader: 'Custom header for telegram source.', // Required: no (optional).
    directory: __dirname + '/logTg', // Required: no. Path must have existing directory for save log files in this directory, if send was unsuccessful.
    botToken: '32145353234:HHFDkgfrsosiDOosgergjdKDFe', // Required: yes.
    channelId: '-1001593045950', // Required: yes.
    message: 'Custom message\nfor message body.' // Required: no (optional).
})

logger
.log('This log will send to all added sources,')
.log('because we use \'report\' function.')
.report()

logger.log('This log will send to all added sources too, cause this text contain \'global test phrase\',')

logger.log('This log will send to console source, cause this text contain \'console test phrase\'.')

logger.log('This log will send to file source, cause this text contain \'file test phrase\'.')

logger.log('This log will send to telegram source, cause this text contain \'telegram test phrase\'.')

logger
.log('And this log didn\'t send to any source, cause we clear all logs by \'clear\' function.')
.clear()

logger
.log('And this log didn\'t send to any source, cause we remove all sources by \'removeSource\'.')
.removeSource('myConsole1')
.removeSource('myFileSource1')
.removeSource('myTelegramSource1')
.report()
```

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