Simple logging library for node.js.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # mLogger
  2. mLogger is a very simple logging library for node.js.
  3. ## Installation
  4. Install like any other NPM library:
  5. ```
  6. npm install --save mlogger
  7. ```
  8. ## Usage
  9. ```
  10. var log = require("mlogger");
  11. ```
  12. Logger has 4 methods for logging:
  13. ```
  14. log.info("foo"); // yyyy/mm/dd HH:MM:SS INFO: foo
  15. log.notice("foo"); // yyyy/mm/dd HH:MM:SS NOTICE: foo
  16. log.warn("foo"); // yyyy/mm/dd HH:MM:SS WARNING: foo
  17. log.error("foo"); // yyyy/mm/dd HH:MM:SS ERROR: foo
  18. log.die("foo"); // yyyy/mm/dd HH:MM:SS ERROR: foo
  19. ```
  20. After log.die, the process will immediately exit.
  21. If an error object is passed instead of a string, a stack trace will be printed, like this:
  22. ```
  23. log.notice(new Error("foo"));
  24. // yyyy/mm/dd HH:MM:SS NOTICE: foo - stack trace:
  25. // Trace: [Error: foo]
  26. // <stack trace>
  27. ```
  28. To set a different color theme, use `setTheme`:
  29. ```
  30. log.setTheme({
  31. timestamp: "green"
  32. })
  33. ```
  34. The available properties for setTheme is:
  35. * timestamp: timestamp, default: "blue"
  36. * level_0: logger.info, default: "grey"
  37. * level_1: logger.notice, default: "yellow"
  38. * level_2: logger.warn, default: "red"
  39. * level_3: logger.die/logger.error, default: ["bold", "red"]
  40. The available values for themes are listed here: https://npmjs.com/package/colors