Update copilot-instructions.md

This commit is contained in:
Enno Gelhaus 2025-07-31 22:53:02 +02:00 committed by GitHub
parent f7899681a5
commit fdddf2ca26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 63 additions and 0 deletions

View File

@ -49,5 +49,68 @@
--- ---
# Logs
- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/nextjs"`
- Enable logging in Sentry using `Sentry.init({ enableLogs: true })`
- Reference the logger using `const { logger } = Sentry`
- Sentry offers a `consoleLoggingIntegration` that can be used to log specific console error types automatically without instrumenting the individual logger calls
## Configuration
The Sentry initialization needs to be updated to enable the logs feature.
### Baseline
```javascript
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
enableLogs: true,
});
```
### Logger Integration
```javascript
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [
// send console.log, console.error, and console.warn calls as logs to Sentry
Sentry.consoleLoggingIntegration({ levels: ["log", "error", "warn"] }),
],
});
```
## Logger Examples
`logger.fmt` is a template literal function that should be used to bring variables into the structured logs.
```javascript
import * as Sentry from "@sentry/nextjs";
const { logger } = Sentry;
logger.trace("Starting database connection", { database: "users" });
logger.debug(logger.fmt`Cache miss for user: ${userId}`);
logger.info("Updated profile", { profileId: 345 });
logger.warn("Rate limit reached for endpoint", {
endpoint: "/api/results/",
isEnterprise: false,
});
logger.error("Failed to process payment", {
orderId: "order_123",
amount: 99.99,
});
logger.fatal("Database connection pool exhausted", {
database: "users",
activeConnections: 100,
});
```
---
For questions or unclear conventions, check the main README or ask for clarification in your PR description. For questions or unclear conventions, check the main README or ask for clarification in your PR description.