Skip to content

Commit a895f68

Browse files
solniclucas-zimerman
authored andcommitted
feat(ruby): Add Integrations section to logs docs (#14413)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Follow up after getsentry/sentry-ruby#2644 (comment) documenting how to set up logs support for Ruby's built-in stdlib Logger. ## Preview 👀 https://sentry-docs-git-ruby-stdlib-logger-docs.sentry.dev/platforms/ruby/logs/#integrations ## 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:* - [x] 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 c7b7a7c commit a895f68

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

docs/platforms/ruby/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ With Sentry Structured Logs, you can send text based log information from your a
2020
## Usage
2121

2222
<PlatformContent includePath="logs/usage" />
23+
24+
## Integrations
25+
26+
<PlatformContent includePath="logs/integrations" />
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
To enable logging for all loggers that use Ruby [Logger](https://ruby-doc.org/3.4.1/stdlibs/logger/Logger.html) you can enable `:logger` patch:
2+
3+
```ruby
4+
Sentry.init do |config|
5+
config.dsn = "___PUBLIC_DSN___"
6+
config.enable_logs = true
7+
config.enabled_patches = [:logger]
8+
end
9+
```
10+
11+
Then all logs from `Logger` instances will be sent to Sentry, for example:
12+
13+
```ruby
14+
logger = Logger.new($stdout)
15+
16+
logger.debug("Hello from stdlib logger")
17+
logger.info("Hello from stdlib logger")
18+
logger.error("Hello from stdlib logger")
19+
```
20+
21+
<Alert level="info" title="Note on structured logging">
22+
Ruby's stdlib logger does not support structured logging, that's why logs are sent to Sentry as plain messages with default attributes added automatically by the SDK.
23+
</Alert>
24+
25+
## Ruby on Rails
26+
27+
If you enable `:logger` patch like explained above, this will affect Rails' built-in logger. This means that anything that Rails logs, and any custom usage of the Rails logger, will result in sending log entries to Sentry, for example:
28+
29+
```ruby
30+
# All these calls will result in log entries in Sentry
31+
# if :logger patch is enabled
32+
Rails.logger.debug("Hello from Rails logger")
33+
Rails.logger.info("Hello from Rails logger")
34+
Rails.logger.error("Hello from Rails logger")
35+
```

0 commit comments

Comments
 (0)