From 6655cdb7676ab5f79fc1d5c3e6859c3651de8a18 Mon Sep 17 00:00:00 2001 From: yiling Date: Sun, 24 May 2026 09:40:53 +0800 Subject: [PATCH] feat(asset): convert purge log to structured format and add logging guide to AGENTS.md --- AGENTS.md | 11 +++++++++++ src/services/asset/asset.ts | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index a125ea8e..efeceb71 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -308,3 +308,14 @@ We use a custom workflow engine that supports both **Local** (polling-based) and ## Radix UI / Shadcn UI Patterns - **Modal Overlays**: When triggering a dialog (e.g., `Dialog`, `AlertDialog`) from inside a `DropdownMenu`, you must set `modal={false}` on the `` component. Failing to do so will cause the UI to freeze due to conflicting focus management between the two modal components. + +## Logging + +We use **pino** for logging. Always use **structured logging** to ensure logs are easily searchable and machine-readable. + +- **Import**: `import { logger } from '@/logger'` +- **Usage**: Pass an object as the first argument containing the metadata, and a string as the second argument for the descriptive message. + ```typescript + logger.info({ userId: user.id, projectId }, 'Project deleted successfully') + ``` +- **Levels**: Use appropriate levels: `debug`, `info`, `warn`, `error`. diff --git a/src/services/asset/asset.ts b/src/services/asset/asset.ts index a1263898..282bc913 100644 --- a/src/services/asset/asset.ts +++ b/src/services/asset/asset.ts @@ -894,6 +894,11 @@ export class AssetService { }) logger.info( + { + purgedCount: successfulIds.length, + physicalFilesDeleted, + physicalFoldersDeleted, + }, `${successfulIds.length} assets purged, deleted ${physicalFilesDeleted} files in ${physicalFoldersDeleted} folders`, ) }