You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
964 B

4 years ago
  1. 'use strict';
  2. var log = require('loglevel').getLogger('webpack-dev-server');
  3. var INFO = 'info';
  4. var WARN = 'warn';
  5. var ERROR = 'error';
  6. var DEBUG = 'debug';
  7. var TRACE = 'trace';
  8. var SILENT = 'silent'; // deprecated
  9. // TODO: remove these at major released
  10. // https://github.com/webpack/webpack-dev-server/pull/1825
  11. var WARNING = 'warning';
  12. var NONE = 'none'; // Set the default log level
  13. log.setDefaultLevel(INFO);
  14. function setLogLevel(level) {
  15. switch (level) {
  16. case INFO:
  17. case WARN:
  18. case ERROR:
  19. case DEBUG:
  20. case TRACE:
  21. log.setLevel(level);
  22. break;
  23. // deprecated
  24. case WARNING:
  25. // loglevel's warning name is different from webpack's
  26. log.setLevel('warn');
  27. break;
  28. // deprecated
  29. case NONE:
  30. case SILENT:
  31. log.disableAll();
  32. break;
  33. default:
  34. log.error("[WDS] Unknown clientLogLevel '".concat(level, "'"));
  35. }
  36. }
  37. module.exports = {
  38. log: log,
  39. setLogLevel: setLogLevel
  40. };