# kailogs

> Logging library for Discord Applications

Latest version **4.1.2** (published 2022-03-07) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.2 |
| Published | 2022-03-07 |
| First published | 2020-12-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Enigma Software |
| Maintainers | theguitarleader |
| Keywords | kai, logging, discord |

## Links

- npm: https://www.npmjs.com/package/kailogs
- Repository: https://github.com/TheGuitarleader/KaiLogs
- Homepage: https://github.com/TheGuitarleader/KaiLogs#readme
- Issues: https://github.com/TheGuitarleader/KaiLogs/issues
- npm.io page: https://npm.io/package/kailogs

## 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

- 4.1.2 (latest) — 2022-03-07
- 4.1.1 — 2022-03-07
- 4.1.0 — 2022-03-07
- 4.0.1 — 2022-03-06
- 4.0.0 — 2022-03-05
- 3.1.1 — 2022-01-01
- 3.1.0 — 2022-01-01
- 3.0.0 — 2021-10-06
- 2.1.1 — 2021-05-15
- 2.1.0 — 2021-05-15
- 2.0.0 — 2020-12-08
- 1.0.3 — 2020-12-05
- 1.0.2 — 2020-12-05
- 1.0.1 — 2020-12-04
- 1.0.0 — 2020-12-03
- … 4 more at https://npm.io/package/kailogs/versions

## README

# KaiLogs
Local logging library for Discord.js bots.
Designed for KaiBot and Quentin Discord Applications.

Turn this:
```
Hey this needs to be logged!
```
Into this:
```
[11:44:55PM] [<location>/INFO]: Hey this needs to be logged!
```

## JavaScript Usage for KaiLogs@4.x.x+

### Create logger
We need to create a new logger with a directory to put the logs.
```javascript
const KaiLogs = require('kailogs');
const logger = new KaiLogs.logger('./logs');
```

### Error handling
KaiLogs can now log uncaught exceptions and rejections.
```javascript
const exception = new KaiLogs.exceptions(logger);
const rejection = new KaiLogs.rejections(logger);
```
After this we need to tell KaiLogs to start handling error events.
```javascript
exception.handle();
rejection.handle();
```
These can be turned off at anytime using the `unhandle()` method.

### Logging levels
KaiLogs has 6 logging levels. Each type of level has its own method.
| Name          | Example      | Usage
| ---------| ----------------| -----------
| `debug` | `logger.debug(message)` | 'message' : string of the message to be logged.
| `error` | `logger.error(message)` | 'message' : string of the message to be logged.
| `info` | `logger.info(message)` | 'message' : string of the message to be logged.
| `log`  | `logger.log(type, message)` | 'type' : custom level type string, 'message' : string of the message to be logged.
| `warn` | `logger.warn(message)` | 'message' : string of the message to be logged.

The `logger.message()` method is intended to log Discord messages for moderation purposes. Requires a [`channel.name`](https://discord.js.org/#/docs/discord.js/stable/class/Channel), [`user.username`](https://discord.js.org/#/docs/discord.js/stable/class/User), and [`message.content`](https://discord.js.org/#/docs/discord.js/stable/class/Message) class. 

### Events

As of KaiLogs@4.1.x, events will emit for each logging level.
```javascript
logger.on('error', (err) => {
    // Emits every time 'logger.error()' is called.
})
```


## JavaScript Usage for KaiLogs@3.x.x

```javascript
const logger = require('kailogs');

// Loads the latest log and continues the logging
logger.loadLog('../logs');

// Writes to log file and prints to console
logger.debug('debug');
logger.error('this is a error');
logger.log('this is a log');
logger.warn('this is a warning');

// Saves file as current date
logger.save();

// Creates a new log file
logger.createLog('../logs');

// Writes only to the console
logger.write('this is not logged', 'function');
```

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