diff --git a/bun.lockb b/bun.lockb index 59c1df6d..4fac7a13 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/gil/__tests__/bot_mongo/index.ts b/packages/gil/__tests__/bot_mongo/index.ts index af6fb753..5060edb1 100644 --- a/packages/gil/__tests__/bot_mongo/index.ts +++ b/packages/gil/__tests__/bot_mongo/index.ts @@ -2,6 +2,7 @@ import { join } from "path"; import "dotenv/config"; import { GilClient } from "../../lib/GilClient"; import { MongoAdapter } from "../../lib/adapters/db/MongoAdapter"; +import { PinoAdapter } from "../../lib/adapters/logging/PinoAdapter"; import mongoose from "mongoose"; import Server from "./db/Server"; @@ -18,6 +19,7 @@ const YokiBot = new GilClient({ token: process.env.TOKEN!, commandDirectory: join(__dirname, "commands"), listenerDirectory: join(__dirname, "listeners"), + loggingAdapter: new PinoAdapter(), databaseAdapter: new MongoAdapter({ serverModel: Server, serverIdKey: "server_id", diff --git a/packages/gil/lib/adapters/logging/PinoAdapter.ts b/packages/gil/lib/adapters/logging/PinoAdapter.ts index e69de29b..d4acc85d 100644 --- a/packages/gil/lib/adapters/logging/PinoAdapter.ts +++ b/packages/gil/lib/adapters/logging/PinoAdapter.ts @@ -0,0 +1,25 @@ +import { pino } from "pino"; +import { LoggerAdapter } from "./LoggerAdapter"; + +export class PinoAdapter extends LoggerAdapter { + public constructor(readonly logger = pino()) { + super(); + } + + public error(error: Error): void { + this.logger.error(error); + } + + public warn(message: string): void { + this.logger.warn(message); + } + + public info(message: string): void { + this.logger.info(message); + } + + public debug(message: string, decorate?: string): void { + if (decorate) this.logger.debug(`[DEBUG] ${decorate}: ${message}`); + else this.logger.debug(`[DEBUG] ${message}`); + } +} diff --git a/packages/gil/lib/adapters/logging/WinstonAdapter.ts b/packages/gil/lib/adapters/logging/WinstonAdapter.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/gil/lib/index.ts b/packages/gil/lib/index.ts index d53367c6..6f131ddb 100644 --- a/packages/gil/lib/index.ts +++ b/packages/gil/lib/index.ts @@ -8,4 +8,4 @@ export * from "./adapters/logging/LoggerAdapter"; export * from "./adapters/db/DatabaseAdapter"; export * from "./adapters/db/MongoAdapter"; // export * from "./adapters/logging/WinstonAdapter"; -// export * from "./adapters/logging/PinoAdapter"; +export * from "./adapters/logging/PinoAdapter"; diff --git a/packages/gil/package.json b/packages/gil/package.json index a7f55eff..b3babcd3 100644 --- a/packages/gil/package.json +++ b/packages/gil/package.json @@ -17,6 +17,7 @@ "@types/mongoose": "^5.11.97", "dotenv": "^16.0.3", "mongoose": "^8.2.3", + "pino": "^8.19.0", "typescript": "5.0.4" }, "dependencies": {