logging.ts 702 B

12345678910111213141516171819
  1. import { createEventLogger, createLogger } from "@shared/common/logging";
  2. import { isHttpError } from "@shared/common/async_utils";
  3. import { HTTPError } from "got/dist/source";
  4. export const logger = createLogger({
  5. errorHandler: (reason) => {
  6. if (isHttpError<HTTPError>(reason)) {
  7. return new Error(`HTTPError: ${reason.request.requestUrl} failed because ${reason}\nStack trace: ${reason.stack}`);
  8. }
  9. return undefined;
  10. }
  11. });
  12. export const eventLogger = createEventLogger({
  13. host: process.env.MONGO_DB_HOST ?? "",
  14. password: process.env.MONGO_DB_USERNAME ?? "",
  15. username: process.env.MONGO_DB_PASSWORD ?? "",
  16. name: "NoctBot",
  17. });