kawadhiya21 / mysql-migrations

A tool to use with mysql package to maintain migrations
MIT License
31 stars 25 forks source link

18 custom log level #36

Open lewismoten opened 2 months ago

lewismoten commented 2 months ago

Resolves #18 with the introduction of two new migration options.

--log-level <threshold> Allows the user to control the level of logging with one of the following: NONE, CRITICAL, ERROR, WARN, INFO, LOG, DEBUG, ALL. It's a lightweight implementation that should be familiar to developers that have worked with Log4<platform> libraries.

migration.init(
  connection,
  __dirname + '/migrations',
  function() {},
  [
    "--log-level ERROR"
  ]
);

--logger allows the developer to specify their own custom logger so long as it exposes methods for error, warn, info, log, debug that accept a string message.

var customLogger = {
  debug: function (message) {
    console.debug(message);
  },
  log: function (message) {
    console.log(message);
  },
  info: function (message) {
    console.info(message);
  },
  warn: function (message) {
    console.warn(message);
  },
  error: function (message) {
    console.error(message);
  },
  critical: function (message) {
    console.error(message);
  }
};

migration.init(
  connection,
  __dirname + '/migrations',
  function() {},
  [
    "--logger",
    customLogger
  ]
);