Skip to content

Commit e9685e6

Browse files
committed
docs(ruby): add sections for std_lib_logger_filter opt
1 parent 2412b50 commit e9685e6

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

docs/platforms/ruby/common/configuration/options.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,16 @@ Provides a lambda or proc that's called with an SDK-specific log object, and can
362362

363363
</SdkOption>
364364

365+
<SdkOption name="std_lib_logger_filter" type="lambda | proc">
366+
367+
Provides a lambda or proc that's called to filter log messages from Ruby's standard library logger before they are sent to Sentry. This option is only used when the `:logger` patch is enabled via `config.enabled_patches`.
368+
369+
The callback receives three arguments: `logger` (the logger instance), `message` (the log message string), and `severity` (the log severity level). Return `true` to send the log to Sentry, or `false` to skip it.
370+
371+
<PlatformContent includePath="configuration/std-lib-logger-filter" />
372+
373+
</SdkOption>
374+
365375
<SdkOption name="before_send_check_in" type="lambda | proc">
366376

367377
Provides a lambda or proc that's called with a check-in event object, and can return a modified check-in event object, or `nil` to skip reporting the event.

docs/platforms/ruby/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ With Sentry Structured Logs, you can send text-based log information from your a
2525

2626
<PlatformContent includePath="logs/integrations" />
2727

28+
## Options
29+
30+
<PlatformContent includePath="logs/options" />
31+
2832
## Default Attributes
2933

3034
<PlatformContent includePath="logs/default-attributes" />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```ruby
2+
Sentry.init do |config|
3+
config.dsn = "___PUBLIC_DSN___"
4+
config.enable_logs = true
5+
config.enabled_patches << :logger
6+
7+
# Only send ERROR and FATAL logs to Sentry
8+
config.std_lib_logger_filter = proc do |logger, message, severity|
9+
[:error, :fatal].include?(severity)
10+
end
11+
end
12+
```

platform-includes/logs/integrations/ruby.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ logger.info("Hello from stdlib logger")
1818
logger.error("Hello from stdlib logger")
1919
```
2020

21+
You can filter which logs are sent to Sentry using the [`std_lib_logger_filter`](/platforms/ruby/configuration/options/#std-lib-logger-filter) configuration option.
22+
2123
<Alert level="info" title="Note on structured logging">
2224
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.
2325
</Alert>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### before_send_log
2+
3+
To filter logs before they are sent to Sentry, use the `before_send_log` callback. Return `nil` to skip a log, or return the log object to send it.
4+
5+
<PlatformContent includePath="configuration/before-send-log" />
6+
7+
### std_lib_logger_filter
8+
9+
When using the `:logger` patch for Ruby's standard library logger, you can filter log messages using `std_lib_logger_filter`. The callback receives the logger instance, message, and severity level. Return `true` to send the log, or `false` to skip it.
10+
11+
<PlatformContent includePath="configuration/std-lib-logger-filter" />

0 commit comments

Comments
 (0)