|
13 | 13 | require "sentry/linecache" |
14 | 14 | require "sentry/interfaces/stacktrace_builder" |
15 | 15 | require "sentry/logger" |
| 16 | +require "sentry/structured_logger" |
16 | 17 | require "sentry/log_event_buffer" |
17 | 18 |
|
18 | 19 | module Sentry |
@@ -201,18 +202,6 @@ def capture_exception_frame_locals=(value) |
201 | 202 | # @return [String, nil] |
202 | 203 | attr_accessor :sdk_debug_transport_log_file |
203 | 204 |
|
204 | | - # File path for DebugStructuredLogger to log events to. If not set, defaults to a temporary file. |
205 | | - # This is useful for debugging and testing structured logging. |
206 | | - # @return [String, nil] |
207 | | - attr_accessor :sdk_debug_structured_logger_log_file |
208 | | - |
209 | | - # The class to use as a structured logger. |
210 | | - # If this option is not set, it will return `nil`, and Sentry will use |
211 | | - # `Sentry::StructuredLogger` by default when logs are enabled. |
212 | | - # |
213 | | - # @return [Class, nil] |
214 | | - attr_reader :structured_logger_class |
215 | | - |
216 | 205 | # @deprecated Use {#sdk_logger=} instead. |
217 | 206 | def logger=(logger) |
218 | 207 | warn "[sentry] `config.logger=` is deprecated. Please use `config.sdk_logger=` instead." |
@@ -306,6 +295,10 @@ def logger |
306 | 295 | # @return [Boolean] |
307 | 296 | attr_accessor :enable_logs |
308 | 297 |
|
| 298 | + # Structured logging configuration. |
| 299 | + # @return [StructuredLoggingConfiguration] |
| 300 | + attr_reader :structured_logging |
| 301 | + |
309 | 302 | # Easier way to use performance tracing |
310 | 303 | # If set to true, will set traces_sample_rate to 1.0 |
311 | 304 | # @deprecated It will be removed in the next major release. |
@@ -502,6 +495,7 @@ def initialize |
502 | 495 | @transport = Transport::Configuration.new |
503 | 496 | @cron = Cron::Configuration.new |
504 | 497 | @metrics = Metrics::Configuration.new |
| 498 | + @structured_logging = StructuredLoggingConfiguration.new |
505 | 499 | @gem_specs = Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map) |
506 | 500 |
|
507 | 501 | run_post_initialization_callbacks |
@@ -624,14 +618,6 @@ def profiler_class=(profiler_class) |
624 | 618 | @profiler_class = profiler_class |
625 | 619 | end |
626 | 620 |
|
627 | | - def structured_logger_class=(klass) |
628 | | - unless klass.is_a?(Class) |
629 | | - raise Sentry::Error.new("config.structured_logger_class must be a class. got: #{klass.class}") |
630 | | - end |
631 | | - |
632 | | - @structured_logger_class = klass |
633 | | - end |
634 | | - |
635 | 621 | def sending_allowed? |
636 | 622 | spotlight || sending_to_dsn_allowed? |
637 | 623 | end |
@@ -809,4 +795,19 @@ def processor_count |
809 | 795 | available_processor_count || Concurrent.processor_count |
810 | 796 | end |
811 | 797 | end |
| 798 | + |
| 799 | + class StructuredLoggingConfiguration |
| 800 | + # File path for DebugStructuredLogger to log events to |
| 801 | + # @return [String, Pathname, nil] |
| 802 | + attr_accessor :file_path |
| 803 | + |
| 804 | + # The class to use as a structured logger. |
| 805 | + # @return [Class] |
| 806 | + attr_accessor :logger_class |
| 807 | + |
| 808 | + def initialize |
| 809 | + @file_path = nil |
| 810 | + @logger_class = Sentry::StructuredLogger |
| 811 | + end |
| 812 | + end |
812 | 813 | end |
0 commit comments