Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zcuric/sql-log-prettifier
A prettifier for your sql logs
https://github.com/zcuric/sql-log-prettifier
logging pino query sequelize sql winston
Last synced: 2 months ago
JSON representation
A prettifier for your sql logs
- Host: GitHub
- URL: https://github.com/zcuric/sql-log-prettifier
- Owner: zcuric
- License: mit
- Created: 2019-10-22T07:46:43.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:14:19.000Z (about 2 years ago)
- Last Synced: 2024-10-14T02:44:55.405Z (3 months ago)
- Topics: logging, pino, query, sequelize, sql, winston
- Language: TypeScript
- Size: 822 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL log prettifier
SQL query prettifier for your favorite logger
## Usage
```sh
npm install sql-log-prettifier
# or
yarn add sql-log-prettifier
```In your project require or import `sql-log-prettifier`
```js
const { prettify } = require('sql-log-prettifier');
// import { prettify } from 'sql-log-prettifier';const unformattedAndUglySql = `SELECT * FROM custom_table WHERE id = 1 AND name = 'Test'`;
console.log(prettify(unformattedAndUglySql));
```
Output will look something like this:## Settings
`prettify` function accepts `settings` as the second argument.
Default settings are:
```js
const defaultSettings = {
format: true,
noColors: false,
settings: {
functions: {
color: '#ff5555',
modifiers: ['bold'],
},
keywords: {
color: '#ff5555',
modifiers: ['bold'],
},
operators: {
color: '#91B859',
modifiers: ['bold'],
},
strings: {
color: '#FFFFF',
},
numbers: {
color: '#50fa7b',
},
},
};
```### TODO:
- Add examples for popular loggers (`pino`, `winston`)
- Update README.md
- Anything else that needs to be done :construction_worker:## Development
`sql-log-prettifer` is built with [`tsdx`](https://github.com/jaredpalmer/tsdx).
```
# Running examples
npm run start# Running tests
npm run test# Running build
npm run build
```## Contributing
All contributions are welcome.
## License
MIT @ Zdravko Ćurić [(zcuric)](https://github.com/zcuric)