Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions platform-includes/llm-rules-platform/_default.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function fetchUserData(userId) {

- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/browser"`
- Enable logging in Sentry using `Sentry.init({ enableLogs: true })`
- Reference the logger using `const { logger } = Sentry`
- Reference the logger using `Sentry.logger`
- Sentry offers a `consoleLoggingIntegration` that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand Down Expand Up @@ -110,25 +110,23 @@ Sentry.init({

## Logger Examples

`logger.fmt` is a template literal function that should be used to bring variables into the structured logs.
`Sentry.logger.fmt` is a template literal function that should be used to bring variables into the structured logs.

```javascript
import * as Sentry from "@sentry/browser";

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", {
Sentry.logger.trace("Starting database connection", { database: "users" });
Sentry.logger.debug(Sentry.logger.fmt`Cache miss for user: ${userId}`);
Sentry.logger.info("Updated profile", { profileId: 345 });
Sentry.logger.warn("Rate limit reached for endpoint", {
endpoint: "/api/results/",
isEnterprise: false,
});
logger.error("Failed to process payment", {
Sentry.logger.error("Failed to process payment", {
orderId: "order_123",
amount: 99.99,
});
logger.fatal("Database connection pool exhausted", {
Sentry.logger.fatal("Database connection pool exhausted", {
database: "users",
activeConnections: 100,
});
Expand Down
2 changes: 1 addition & 1 deletion platform-includes/llm-rules-platform/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function fetchUserData(userId) {

- 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`
- Reference the logger using `Sentry.logger`
- Sentry offers a consoleLoggingIntegration that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion platform-includes/llm-rules-platform/javascript.node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function fetchUserData(userId) {

- Where logs are used, ensure they are imported using `import * as Sentry from "@sentry/node"`
- Enable logging in Sentry using `Sentry.init({ enableLogs: true, })`
- Reference the logger using `const { logger } = Sentry`
- Reference the logger using `Sentry.logger`
- Sentry offers a consoleLoggingIntegration that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion platform-includes/llm-rules-platform/javascript.react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function fetchUserData(userId) {

- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/react"`
- Enable logging in Sentry using `Sentry.init({ enableLogs: true })`
- Reference the logger using `const { logger } = Sentry`
- Reference the logger using `Sentry.logger`
- Sentry offers a consoleLoggingIntegration that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand Down
Loading