Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18 custom log level #36

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

lewismoten
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please leave logging a user's choice
1 participant