|
| 1 | +require "logtail" |
| 2 | + |
| 3 | +Logtail::Config.instance.define_singleton_method(:logrageify!) do |
| 4 | + integrations.rack.http_events.collapse_into_single_event = true |
| 5 | +end |
| 6 | + |
| 7 | +module Logtail |
| 8 | + class Config |
| 9 | + module Integrations |
| 10 | + extend self |
| 11 | + # Convenience module for accessing the various `Logtail::Integrations::Rack::*` classes |
| 12 | + # through the {Logtail::Config} object. Logtail couples configuration with the class |
| 13 | + # responsibls for implementing it. This provides for a tighter design, but also |
| 14 | + # requires the user to understand and access the various classes. This module aims |
| 15 | + # to provide a simple ruby-like configuration interface for internal Logtail classes. |
| 16 | + # |
| 17 | + # For example: |
| 18 | + # |
| 19 | + # config = Logtail::Config.instance |
| 20 | + # config.integrations.rack.http_events.enabled = false |
| 21 | + def rack |
| 22 | + Rack |
| 23 | + end |
| 24 | + |
| 25 | + module Rack |
| 26 | + extend self |
| 27 | + |
| 28 | + # Convenience method for accessing the {Logtail::Integrations::Rack::ErrorEvent} |
| 29 | + # middleware class specific configuration. See {Logtail::Integrations::Rack::ExceptionEvent} |
| 30 | + # for a list of methods available. |
| 31 | + # |
| 32 | + # @example |
| 33 | + # config = Logtail::Config.instance |
| 34 | + # config.integrations.rack.error_event.enabled = false |
| 35 | + def error_event |
| 36 | + Logtail::Integrations::Rack::ErrorEvent |
| 37 | + end |
| 38 | + |
| 39 | + # Convenience method for accessing the {Logtail::Integrations::Rack::HTTPContext} |
| 40 | + # middleware class specific configuration. See {Logtail::Integrations::Rack::HTTPContext} |
| 41 | + # for a list of methods available. |
| 42 | + # |
| 43 | + # @example |
| 44 | + # config = Logtail::Config.instance |
| 45 | + # config.integrations.rack.http_context.enabled = false |
| 46 | + def http_context |
| 47 | + Logtail::Integrations::Rack::HTTPContext |
| 48 | + end |
| 49 | + |
| 50 | + # Convenience method for accessing the {Logtail::Integrations::Rack::HTTPEvents} |
| 51 | + # middleware class specific configuration. See {Logtail::Integrations::Rack::HTTPEvents} |
| 52 | + # for a list of methods available. |
| 53 | + # |
| 54 | + # @example |
| 55 | + # config = Logtail::Config.instance |
| 56 | + # config.integrations.rack.http_events.enabled = false |
| 57 | + def http_events |
| 58 | + Logtail::Integrations::Rack::HTTPEvents |
| 59 | + end |
| 60 | + |
| 61 | + # Convenience method for accessing the {Logtail::Integrations::Rack::SessionContext} |
| 62 | + # middleware class specific configuration. See {Logtail::Integrations::Rack::SessionContext} |
| 63 | + # for a list of methods available. |
| 64 | + # |
| 65 | + # @example |
| 66 | + # config = Logtail::Config.instance |
| 67 | + # config.integrations.rack.session_context.enabled = false |
| 68 | + def session_context |
| 69 | + Logtail::Integrations::Rack::SessionContext |
| 70 | + end |
| 71 | + |
| 72 | + # Convenience method for accessing the {Logtail::Integrations::Rack::UserContext} |
| 73 | + # middleware class specific configuration. See {Logtail::Integrations::Rack::UserContext} |
| 74 | + # for a list of methods available. |
| 75 | + # |
| 76 | + # @example |
| 77 | + # config = Logtail::Config.instance |
| 78 | + # config.integrations.rack.user_context.enabled = false |
| 79 | + def user_context |
| 80 | + Logtail::Integrations::Rack::UserContext |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | + end |
| 85 | +end |
0 commit comments