Module: Logtail::Integrations::Rails

Defined in:
lib/logtail-rails.rb,
lib/logtail-rails/version.rb,
lib/logtail-rails/error_event.rb,
lib/logtail-rails/rack_logger.rb,
lib/logtail-rails/session_context.rb,
lib/logtail-rails/active_support_log_subscriber.rb

Overview

Module for holding all Rails integrations. This module does not extend Integration because it’s dependent on Rack::HTTPEvents. This module simply disables the default HTTP request logging.

Defined Under Namespace

Modules: ActiveSupportLogSubscriber Classes: ErrorEvent, RackLogger, SessionContext

Constant Summary collapse

VERSION =
"0.2.6"

Class Method Summary collapse

Class Method Details

.enabled=(value) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/logtail-rails.rb', line 49

def self.enabled=(value)
  Logtail::Integrations::Rails::ErrorEvent.enabled = value
  Logtail::Integrations::Rack::HTTPContext.enabled = value
  Logtail::Integrations::Rack::HTTPEvents.enabled = value
  Logtail::Integrations::Rack::UserContext.enabled = value
  SessionContext.enabled = value

  ActionController.enabled = value
  ActionView.enabled = value
  ActiveRecord.enabled = value
end

.enabled?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/logtail-rails.rb', line 35

def self.enabled?
  Logtail::Integrations::Rack::HTTPEvents.enabled?
end

.integrate!Object



39
40
41
42
43
44
45
46
47
# File 'lib/logtail-rails.rb', line 39

def self.integrate!
  return false if !enabled?

  ActionController.integrate!
  ActionDispatch.integrate!
  ActionView.integrate!
  ActiveRecord.integrate!
  RackLogger.integrate!
end

.middlewaresObject

All enabled middlewares. The order is relevant. Middlewares that set context are added first so that context is included in subsequent log lines.



63
64
65
66
# File 'lib/logtail-rails.rb', line 63

def self.middlewares
  @middlewares ||= [Logtail::Integrations::Rack::HTTPContext, SessionContext, Logtail::Integrations::Rack::UserContext,
    Logtail::Integrations::Rack::HTTPEvents, Logtail::Integrations::Rails::ErrorEvent].select(&:enabled?)
end