Skip to content

Commit 1d1ad24

Browse files
authored
neat(logs) prefer to use Sentry.logger over const { logger } (#15743)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR * Update to `Sentry.logger` from `const { logger } = Sentry` in AI docs for logs ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent af970c8 commit 1d1ad24

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

platform-includes/llm-rules-platform/_default.mdx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function fetchUserData(userId) {
7979

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

8585
## Configuration
@@ -110,25 +110,23 @@ Sentry.init({
110110

111111
## Logger Examples
112112

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

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

118-
const { logger } = Sentry;
119-
120-
logger.trace("Starting database connection", { database: "users" });
121-
logger.debug(logger.fmt`Cache miss for user: ${userId}`);
122-
logger.info("Updated profile", { profileId: 345 });
123-
logger.warn("Rate limit reached for endpoint", {
118+
Sentry.logger.trace("Starting database connection", { database: "users" });
119+
Sentry.logger.debug(Sentry.logger.fmt`Cache miss for user: ${userId}`);
120+
Sentry.logger.info("Updated profile", { profileId: 345 });
121+
Sentry.logger.warn("Rate limit reached for endpoint", {
124122
endpoint: "/api/results/",
125123
isEnterprise: false,
126124
});
127-
logger.error("Failed to process payment", {
125+
Sentry.logger.error("Failed to process payment", {
128126
orderId: "order_123",
129127
amount: 99.99,
130128
});
131-
logger.fatal("Database connection pool exhausted", {
129+
Sentry.logger.fatal("Database connection pool exhausted", {
132130
database: "users",
133131
activeConnections: 100,
134132
});

platform-includes/llm-rules-platform/javascript.nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function fetchUserData(userId) {
7979

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

8585
## Configuration

platform-includes/llm-rules-platform/javascript.node.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function fetchUserData(userId) {
7474

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

8080
## Configuration

platform-includes/llm-rules-platform/javascript.react.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function fetchUserData(userId) {
7474

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

8080
## Configuration

0 commit comments

Comments
 (0)