logger-test.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. var vows = require('vows')
  3. , assert = require('assert')
  4. , levels = require('../lib/levels')
  5. , Logger = require('../lib/logger').Logger;
  6. vows.describe('../lib/logger').addBatch({
  7. 'constructor with no parameters': {
  8. topic: new Logger(),
  9. 'should use default category': function(logger) {
  10. assert.equal(logger.category, Logger.DEFAULT_CATEGORY);
  11. },
  12. 'should use TRACE log level': function(logger) {
  13. assert.equal(logger.level, levels.TRACE);
  14. }
  15. },
  16. 'constructor with category': {
  17. topic: new Logger('cheese'),
  18. 'should use category': function(logger) {
  19. assert.equal(logger.category, 'cheese');
  20. },
  21. 'should use TRACE log level': function(logger) {
  22. assert.equal(logger.level, levels.TRACE);
  23. }
  24. },
  25. 'constructor with category and level': {
  26. topic: new Logger('cheese', 'debug'),
  27. 'should use category': function(logger) {
  28. assert.equal(logger.category, 'cheese');
  29. },
  30. 'should use level': function(logger) {
  31. assert.equal(logger.level, levels.DEBUG);
  32. }
  33. },
  34. 'isLevelEnabled': {
  35. topic: new Logger('cheese', 'info'),
  36. 'should provide a level enabled function for all levels': function(logger) {
  37. assert.isFunction(logger.isTraceEnabled);
  38. assert.isFunction(logger.isDebugEnabled);
  39. assert.isFunction(logger.isInfoEnabled);
  40. assert.isFunction(logger.isWarnEnabled);
  41. assert.isFunction(logger.isErrorEnabled);
  42. assert.isFunction(logger.isFatalEnabled);
  43. },
  44. 'should return the right values': function(logger) {
  45. assert.isFalse(logger.isTraceEnabled());
  46. assert.isFalse(logger.isDebugEnabled());
  47. assert.isTrue(logger.isInfoEnabled());
  48. assert.isTrue(logger.isWarnEnabled());
  49. assert.isTrue(logger.isErrorEnabled());
  50. assert.isTrue(logger.isFatalEnabled());
  51. }
  52. }
  53. }).exportTo(module);