common.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * common.js: Internal helper and utility functions for winston.
  3. *
  4. * (C) 2010 Charlie Robbins
  5. * MIT LICENCE
  6. */
  7. 'use strict';
  8. var _require = require('util'),
  9. format = _require.format;
  10. /**
  11. * Set of simple deprecation notices and a way to expose them for a set of
  12. * properties.
  13. * @type {Object}
  14. * @private
  15. */
  16. exports.warn = {
  17. deprecated: function deprecated(prop) {
  18. return function () {
  19. throw new Error(format('{ %s } was removed in winston@3.0.0.', prop));
  20. };
  21. },
  22. useFormat: function useFormat(prop) {
  23. return function () {
  24. throw new Error([format('{ %s } was removed in winston@3.0.0.', prop), 'Use a custom winston.format = winston.format(function) instead.'].join('\n'));
  25. };
  26. },
  27. forFunctions: function forFunctions(obj, type, props) {
  28. props.forEach(function (prop) {
  29. obj[prop] = exports.warn[type](prop);
  30. });
  31. },
  32. forProperties: function forProperties(obj, type, props) {
  33. props.forEach(function (prop) {
  34. var notice = exports.warn[type](prop);
  35. Object.defineProperty(obj, prop, {
  36. get: notice,
  37. set: notice
  38. });
  39. });
  40. }
  41. };