index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. /*
  3. * @api public
  4. * @property {function} format
  5. * Both the construction method and set of exposed
  6. * formats.
  7. */
  8. var 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: function 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');