index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. /*
  3. * @api public
  4. * @property {function} format
  5. * Both the construction method and set of exposed
  6. * formats.
  7. */
  8. const format = exports.format = require('./format');
  9. /*
  10. * @api public
  11. * @method {function} levels
  12. * Registers the specified levels with logform.
  13. */
  14. exports.levels = require('./levels');
  15. /*
  16. * @api private
  17. * method {function} exposeFormat
  18. * Exposes a sub-format on the main format object
  19. * as a lazy-loaded getter.
  20. */
  21. function exposeFormat(name, path) {
  22. path = path || name;
  23. Object.defineProperty(format, name, {
  24. get() {
  25. return require(`./${path}.js`);
  26. },
  27. configurable: true
  28. });
  29. }
  30. //
  31. // Setup all transports as lazy-loaded getters.
  32. //
  33. exposeFormat('align');
  34. exposeFormat('cli');
  35. exposeFormat('combine');
  36. exposeFormat('colorize');
  37. exposeFormat('json');
  38. exposeFormat('label');
  39. exposeFormat('logstash');
  40. exposeFormat('metadata');
  41. exposeFormat('ms');
  42. exposeFormat('padLevels', 'pad-levels');
  43. exposeFormat('prettyPrint', 'pretty-print');
  44. exposeFormat('printf');
  45. exposeFormat('simple');
  46. exposeFormat('splat');
  47. exposeFormat('timestamp');
  48. exposeFormat('uncolorize');