0.1.2 • Published 4 years ago

sql-log-prettifier v0.1.2

Weekly downloads
105
License
MIT
Repository
github
Last release
4 years ago

SQL log prettifier

SQL query prettifier for your favorite logger

Usage

npm install sql-log-prettifier
# or
yarn add sql-log-prettifier

In your project require or import sql-log-prettifier

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:

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.

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

0.1.2

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago