logger.js 711 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. /**
  3. * Sequelize module for debug and deprecation messages.
  4. * It require a `context` for which messages will be printed.
  5. *
  6. * @module logging
  7. * @private
  8. */
  9. const debug = require('debug');
  10. const util = require('util');
  11. class Logger {
  12. constructor(config) {
  13. this.config = {
  14. context: 'sequelize',
  15. debug: true,
  16. ...config
  17. };
  18. }
  19. warn(message) {
  20. // eslint-disable-next-line no-console
  21. console.warn(`(${this.config.context}) Warning: ${message}`);
  22. }
  23. inspect(value) {
  24. return util.inspect(value, false, 3);
  25. }
  26. debugContext(name) {
  27. return debug(`${this.config.context}:${name}`);
  28. }
  29. }
  30. exports.logger = new Logger();
  31. exports.Logger = Logger;