mysql-migrations icon indicating copy to clipboard operation
mysql-migrations copied to clipboard

18 custom log level

Open lewismoten opened this issue 8 months ago • 0 comments

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
  ]
);

lewismoten avatar Jun 03 '24 21:06 lewismoten