Socket
Socket
Sign inDemoInstall

sequelize-log-syntax-colors

Package Overview
Dependencies
6
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sequelize-log-syntax-colors

Colors for sequilize console output. Supporting basic MySQL syntax.


Version published
Weekly downloads
297
decreased by-1%
Maintainers
1
Install size
337 kB
Created
Weekly downloads
 

Readme

Source

Sequilize SQL syntax highlight

Whats it all about?

Default sequelize logger is simply really hard to read and understand:

alt tag

So with a magic of regular expressions and one bier basic MySQL syntax highlight were created:

alt tag

How to use?
  • Install via npm
npm install sequelize-log-syntax-colors
  • Use in code
// require logger
var sequelizeLogger = require('sequelize-log-syntax-colors');
// require config
var config = require(path.join(__dirname, '/../config/config.json'))[env];

// pass a logger function to config
config.logging = sequelizeLogger;

// initialize sequlize
const sequelize = new Sequelize(config.database, config.username, config.password, assign(config, {
  logging : function(text) { console.log(colors(text)); }
}));

// OR use it with Winston

const log = require('./my-loggers');
const sequelize = new Sequelize(config.database, config.username, config.password, assign(config, {
  logging : log.database.info
}));

// setting up winstons loggers
const winston = require('winston');
const common = require('../../node_modules/winston/lib/winston/common');
const colors = require('sequelize-log-syntax-colors');

winston.loggers.add('database', {
  console: {
    level: 'info',
    colorize: true,
    label: 'sequelize',
    formatter: function(obj) {
      var colorfull = {
        colorize: true,
        label: obj.label,
        level: obj.level,
        message: colors(obj.message)
      }
      return common.log(colorfull);
    }
  },
  ...
});

module.exports = winston.loggers.loggers;

Final note

This is still very basic but serves me well. Commitment much appreciated.

Keywords

FAQs

Last updated on 30 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc