Skip to content

Commit

Permalink
Update transports.md
Browse files Browse the repository at this point in the history
Clean up some of the verbiage and remove some redundancy
  • Loading branch information
DABH authored May 9, 2024
1 parent 2756a25 commit 96c9e2b
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions docs/transports.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,9 @@ The Mail transport uses [node-mail][17] behind the scenes. Options are the foll

### MySQL Transport

[winston-mysql](https://github.com/charles-zh/winston-mysql) is MySQL plugin for winston logger.
[winston-mysql](https://github.com/charles-zh/winston-mysql) is a MySQL transport for Winston.

#### installation

Creates a table in the database first:
Create a table in your database first:

```sql
CREATE TABLE `sys_logs_default` (
Expand All @@ -660,20 +658,9 @@ Creates a table in the database first:
PRIMARY KEY (`id`));
```

> Or you can use the JSON format meta field in MySQL database table. That is great for searching & parsing, but it only supports MySQL 5.7+. Bellow the same example but using JSON field.
```sql
CREATE TABLE `sys_logs_json` (
`id` INT NOT NULL AUTO_INCREMENT,
`level` VARCHAR(16) NOT NULL,
`message` VARCHAR(2048) NOT NULL,
`meta` JSON NOT NULL,
`timestamp` DATETIME NOT NULL,
PRIMARY KEY (`id`));

```
> You can also specify `meta` to be a `JSON` field on MySQL 5.7+, i.e., ``meta` JSON NOT NULL`, which is helfpul for searching and parsing.
Configs the transport to winston:
Configure Winston with the transport:

```javascript
import MySQLTransport from 'winston-mysql';
Expand Down

0 comments on commit 96c9e2b

Please sign in to comment.