Giter Club home page Giter Club logo

sql-log-prettifier's Introduction

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 πŸ‘·

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)

sql-log-prettifier's People

Contributors

zcuric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.