feat(asset): convert purge log to structured format and add logging guide to AGENTS.md

This commit is contained in:
yiling
2026-05-24 09:40:53 +08:00
parent c990e77478
commit 6655cdb767
2 changed files with 16 additions and 0 deletions
+11
View File
@@ -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 `<DropdownMenu>` 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`.
+5
View File
@@ -894,6 +894,11 @@ export class AssetService {
})
logger.info(
{
purgedCount: successfulIds.length,
physicalFilesDeleted,
physicalFoldersDeleted,
},
`${successfulIds.length} assets purged, deleted ${physicalFilesDeleted} files in ${physicalFoldersDeleted} folders`,
)
}