Brak opisu
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.

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));