暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.logger = void 0;
  4. const winston = require("winston");
  5. function expandErrors(logger) {
  6. const oldLogFunc = logger.log.bind(logger);
  7. const newLogFunc = function (levelOrEntry, message, ...meta) {
  8. if (message && message instanceof Error) {
  9. message = message.stack || message.message;
  10. return oldLogFunc(levelOrEntry, message, ...meta);
  11. }
  12. return oldLogFunc(levelOrEntry, message, ...meta);
  13. };
  14. logger.log = newLogFunc;
  15. return logger;
  16. }
  17. function annotateDebugLines(logger) {
  18. const debug = logger.debug.bind(logger);
  19. const newDebug = function (message, ...meta) {
  20. if (typeof message === "string") {
  21. message = `[${new Date().toISOString()}] ${message || ""}`;
  22. }
  23. return debug(message, ...meta);
  24. };
  25. logger.debug = newDebug;
  26. return logger;
  27. }
  28. const rawLogger = winston.createLogger();
  29. rawLogger.add(new winston.transports.Console({ silent: true }));
  30. rawLogger.exitOnError = false;
  31. exports.logger = annotateDebugLines(expandErrors(rawLogger));