From 26f3817021a2ae9399cb9eb90e56caf960ad398f Mon Sep 17 00:00:00 2001 From: rjawesome Date: Fri, 1 Nov 2024 12:03:08 -0700 Subject: [PATCH] add template to creative debug --- src/config/index.ts | 2 +- src/controllers/association.ts | 2 +- src/controllers/async/asyncquery_queue.ts | 2 +- src/controllers/cron/clear_edge_cache.ts | 2 +- src/controllers/cron/update_local_smartapi.ts | 2 +- src/controllers/meta_knowledge_graph.ts | 3 ++- src/controllers/opentelemetry.ts | 2 +- src/controllers/threading/taskHandler.ts | 2 +- src/controllers/threading/threadHandler.ts | 2 +- src/middlewares/error.ts | 2 +- src/routes/bullboard.ts | 2 +- src/routes/performance.ts | 2 +- src/routes/v1/asyncquery_status.ts | 2 +- src/server.ts | 2 +- 14 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/config/index.ts b/src/config/index.ts index 68bb76b..c2d305f 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -6,7 +6,7 @@ import helmet from "helmet"; import dotenv from "dotenv"; import * as Sentry from "@sentry/node"; import { Express } from "express"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:server-config"); export default class Config { diff --git a/src/controllers/association.ts b/src/controllers/association.ts index 1c206a7..68f7c46 100644 --- a/src/controllers/association.ts +++ b/src/controllers/association.ts @@ -3,7 +3,7 @@ import fs from "fs"; import path from "path"; import util from "util"; const readFile = util.promisify(fs.readFile); -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:metakg"); export interface AssocResult { diff --git a/src/controllers/async/asyncquery_queue.ts b/src/controllers/async/asyncquery_queue.ts index a536b5e..8b0560a 100644 --- a/src/controllers/async/asyncquery_queue.ts +++ b/src/controllers/async/asyncquery_queue.ts @@ -2,7 +2,7 @@ import "@biothings-explorer/types"; import Queue, { Queue as BullQueue, FailedEventCallback } from "bull"; import axios from "axios"; import { redisClient, getNewRedisClient } from "@biothings-explorer/utils"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; import { TrapiLog, TrapiQueryGraph } from "@biothings-explorer/types"; import { BullJob } from "../../types"; const debug = Debug("bte:biothings-explorer-trapi:asyncquery_queue"); diff --git a/src/controllers/cron/clear_edge_cache.ts b/src/controllers/cron/clear_edge_cache.ts index 0b24f9f..6621e3b 100644 --- a/src/controllers/cron/clear_edge_cache.ts +++ b/src/controllers/cron/clear_edge_cache.ts @@ -1,5 +1,5 @@ import { redisClient } from "@biothings-explorer/utils"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:cron"); import cron from "node-cron"; diff --git a/src/controllers/cron/update_local_smartapi.ts b/src/controllers/cron/update_local_smartapi.ts index 502e806..7bff9cd 100644 --- a/src/controllers/cron/update_local_smartapi.ts +++ b/src/controllers/cron/update_local_smartapi.ts @@ -1,4 +1,4 @@ -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:cron"); import axios from "axios"; import fs from "fs/promises"; diff --git a/src/controllers/meta_knowledge_graph.ts b/src/controllers/meta_knowledge_graph.ts index 7affdc5..1eecaad 100644 --- a/src/controllers/meta_knowledge_graph.ts +++ b/src/controllers/meta_knowledge_graph.ts @@ -2,7 +2,8 @@ import meta_kg, { KGQualifiersObject } from "@biothings-explorer/smartapi-kg"; import { snakeCase } from "snake-case"; import path from "path"; import PredicatesLoadingError from "../utils/errors/predicates_error"; -const debug = require("debug")("bte:biothings-explorer-trapi:metakg"); +import { Debug } from "@biothings-explorer/utils"; +const debug = Debug("bte:biothings-explorer-trapi:metakg"); import apiList from "../config/api_list"; import { supportedLookups } from "@biothings-explorer/query_graph_handler"; diff --git a/src/controllers/opentelemetry.ts b/src/controllers/opentelemetry.ts index d3e579c..b0457c4 100644 --- a/src/controllers/opentelemetry.ts +++ b/src/controllers/opentelemetry.ts @@ -3,7 +3,7 @@ import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node"; import { HttpInstrumentation } from "@opentelemetry/instrumentation-http"; import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express"; import { Resource } from "@opentelemetry/resources"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; const debug = Debug("bte:biothings-explorer:otel-init"); import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'; diff --git a/src/controllers/threading/taskHandler.ts b/src/controllers/threading/taskHandler.ts index 586adf7..dfb9392 100644 --- a/src/controllers/threading/taskHandler.ts +++ b/src/controllers/threading/taskHandler.ts @@ -2,7 +2,7 @@ import "../opentelemetry"; import { isMainThread, threadId } from "worker_threads"; import Piscina from "piscina"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug(`bte:biothings-explorer-trapi:worker${threadId}`); if (!isMainThread) { diff --git a/src/controllers/threading/threadHandler.ts b/src/controllers/threading/threadHandler.ts index 6a6916a..679bd24 100644 --- a/src/controllers/threading/threadHandler.ts +++ b/src/controllers/threading/threadHandler.ts @@ -1,5 +1,5 @@ import { MessageChannel, threadId } from "worker_threads"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; import { context, propagation, trace, Context, Span } from "@opentelemetry/api"; const debug = Debug("bte:biothings-explorer-trapi:threading"); import path from "path"; diff --git a/src/middlewares/error.ts b/src/middlewares/error.ts index 219dc64..b070314 100644 --- a/src/middlewares/error.ts +++ b/src/middlewares/error.ts @@ -3,7 +3,7 @@ import { InvalidQueryGraphError, NotImplementedError } from "@biothings-explorer import PredicatesLoadingError from "../utils/errors/predicates_error"; import MetaKGLoadingError from "../utils/errors/metakg_error"; import ServerOverloadedError from "../utils/errors/server_overloaded_error"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:error_handler"); import * as Sentry from "@sentry/node"; import { Express, NextFunction, Request, Response } from "express"; diff --git a/src/routes/bullboard.ts b/src/routes/bullboard.ts index 33b1fcf..685540f 100644 --- a/src/routes/bullboard.ts +++ b/src/routes/bullboard.ts @@ -2,7 +2,7 @@ import { getQueryQueue } from "../controllers/async/asyncquery_queue"; import { createBullBoard } from "@bull-board/api"; import { BullAdapter } from "@bull-board/api/bullAdapter"; import { ExpressAdapter } from "@bull-board/express"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:bullboard"); import { redisClient } from "@biothings-explorer/utils"; import { Express, NextFunction, Request, Response } from "express"; diff --git a/src/routes/performance.ts b/src/routes/performance.ts index 5f3ae83..174ff32 100644 --- a/src/routes/performance.ts +++ b/src/routes/performance.ts @@ -1,6 +1,6 @@ import path from "path"; import fs from "fs"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:performance"); import * as utils from "../utils/common"; import { Express } from "express"; diff --git a/src/routes/v1/asyncquery_status.ts b/src/routes/v1/asyncquery_status.ts index 5e981cb..3f0d1bb 100644 --- a/src/routes/v1/asyncquery_status.ts +++ b/src/routes/v1/asyncquery_status.ts @@ -6,7 +6,7 @@ import * as utils from "../../utils/common"; import swaggerValidation from "../../middlewares/validate"; import { runTask, taskResponse, taskError } from "../../controllers/threading/threadHandler"; -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:async"); import { Express, NextFunction, Request, RequestHandler, Response } from "express"; import { TaskInfo, TrapiAsyncStatusResponse, TrapiLog, TrapiResponse } from "@biothings-explorer/types"; diff --git a/src/server.ts b/src/server.ts index db06ef3..f0410cb 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,4 +1,4 @@ -import Debug from "debug"; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug("bte:biothings-explorer-trapi:server-start"); async function main() {