From a789e5934e1fbc2eacde42d34e9cacf0a9a3ea07 Mon Sep 17 00:00:00 2001 From: Peter Karolyi Date: Fri, 3 May 2024 17:17:13 +0200 Subject: [PATCH] feat: add some basic logging --- src/artifacts/artifacts.controller.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/artifacts/artifacts.controller.ts b/src/artifacts/artifacts.controller.ts index 1eb9444..a660b51 100644 --- a/src/artifacts/artifacts.controller.ts +++ b/src/artifacts/artifacts.controller.ts @@ -4,6 +4,7 @@ import { Get, Head, HttpCode, + Logger, NotFoundException, Param, Post, @@ -18,10 +19,13 @@ import { ArtifactQueryTeamPipe } from "./artifacts.pipe"; @Controller({ path: "artifacts", version: "8" }) export class ArtifactsController { + private readonly logger = new Logger(ArtifactsController.name); + constructor(private readonly storageService: StorageService) {} @Get("status") getStatus(): StatusRO { + this.logger.debug("GET /v8/artifacts/status"); return { status: "enabled" }; } @@ -30,6 +34,7 @@ export class ArtifactsController { @Param("hash") hash: string, @Query(new ArtifactQueryTeamPipe()) team: string, ): Promise { + this.logger.debug(`HEAD /v8/artifacts/${hash} team: ${team}`); const exists = await this.storageService.exists(team, hash); if (!exists) throw new NotFoundException("Artifact not found"); } @@ -39,6 +44,7 @@ export class ArtifactsController { @Param("hash") hash: string, @Query(new ArtifactQueryTeamPipe()) team: string, ): Promise { + this.logger.debug(`GET /v8/artifacts/${hash} team: ${team}`); const exists = await this.storageService.exists(team, hash); if (!exists) throw new NotFoundException("Artifact not found"); @@ -52,6 +58,9 @@ export class ArtifactsController { @Query(new ArtifactQueryTeamPipe()) team: string, @Body() body: Buffer, ): Promise { + this.logger.debug( + `PUT /v8/artifacts/${hash} team: ${team} body.length: ${body.length}`, + ); await this.storageService.write(team, hash, Readable.from(body)); return { urls: [`${team}/${hash}`] }; }