# bunyan-mysql2

> A Bunyan stream for sending log data to MySQL driver version 2

Latest version **0.0.2** (published 2022-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install bunyan-mysql2
pnpm add bunyan-mysql2
yarn add bunyan-mysql2
bun add bunyan-mysql2
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2022-10-06 |
| First published | 2022-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | williamcc89 |
| Maintainers | williamcc89 |
| Keywords | Bunyan, Mysql, Mysql2 |

## Links

- npm: https://www.npmjs.com/package/bunyan-mysql2
- Repository: https://github.com/williamcc89/bunyan-mysql2
- Issues: https://github.com/williamcc89/bunyan-mysql2/issues
- npm.io page: https://npm.io/package/bunyan-mysql2

## Dependencies (2)

- [moment](https://npm.io/package/moment.md) ^2.14.1
- [mysql2](https://npm.io/package/mysql2.md) ^2.3.3

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

- 0.0.2 (latest) — 2022-10-06
- 0.0.1 — 2022-08-24

## README

bunyan-mysql2
====================

A Bunyan stream for saving logs into Mysql.

## Install

```
npm install bunyan-mysql2
```

## Create Table

Create table in your host

```
CREATE TABLE log(
	name varchar(200),
	hostname varchar(200),
	msg varchar(21845),
	pid integer,
	level integer,
	time datetime,
	v integer
);
```

## Example

```
var bunyan      = require('bunyan');
var MySqlStream = require('bunyan-mysql2');

var msqlStream = new MySqlStream({
    host     : 'localhost',
    user     : 'user',
    password : 'pass',
    database : 'database',
    port     : 3306
});

msqlStream.on('error', function (err) {
    console.log('MySQL Stream Error:', err.stack);
});

var log = bunyan.createLogger({
    name: "My Application",
    streams: [
        { stream: process.stdout },
        { stream: msqlStream }
    ],
    serializers: bunyan.stdSerializers
});

log.info('Oh My God, this works!!!');

```

## Options

* `host`: The hostname of the database you are connecting to. (Default: `localhost`)
* `user`: The MySQL user to authenticate as.
* `password`: The password of that MySQL user.
* `database`: Name of the database to use for this connection (Optional).
* `port`: The port number to connect to. (Default: `3306`)
* `table`: Name of table log. (Default: `log`)
* `connectionLimit`: The maximum number of connections to create at once.
  (Default: `10`)

## Credits

Package developed based on [bunyan-mysql](https://www.npmjs.com/package/bunyan-mysql) package.

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