Module: Logjoy
- Defined in:
- lib/logjoy.rb,
lib/logjoy/railtie.rb,
lib/logjoy/version.rb,
lib/logjoy/log_subscribers/action_controller.rb
Defined Under Namespace
Modules: LogSubscribers
Classes: Error, Railtie
Constant Summary
collapse
- REPLACE_SUBSCRIBERS =
%i[action_controller].freeze
- DETACH_SUBSCRIBERS =
%i[action_view action_mailer active_storage].freeze
- VERSION =
'1.0.0'
Class Method Summary
collapse
Class Method Details
.attach_subscriber(app, component) ⇒ Object
46
47
48
49
50
|
# File 'lib/logjoy.rb', line 46
def attach_subscriber(app, component)
return unless enabled?(app)
logjoy_subscriber(component).attach_to(component)
end
|
.custom_fields(event) ⇒ Object
19
20
21
22
23
|
# File 'lib/logjoy.rb', line 19
def custom_fields(event)
return {} if customizer.nil?
customizer.call(event)
end
|
.default_subscriber(component) ⇒ Object
52
53
54
|
# File 'lib/logjoy.rb', line 52
def default_subscriber(component)
"#{component.to_s.camelize}::LogSubscriber".constantize
end
|
.detach_default_subscriber(app, component) ⇒ Object
40
41
42
43
44
|
# File 'lib/logjoy.rb', line 40
def detach_default_subscriber(app, component)
return unless enabled?(app)
default_subscriber(component).detach_from(component)
end
|
.enabled?(app) ⇒ Boolean
60
61
62
|
# File 'lib/logjoy.rb', line 60
def enabled?(app)
app.config.logjoy.enabled
end
|
.logjoy_subscriber(component) ⇒ Object
56
57
58
|
# File 'lib/logjoy.rb', line 56
def logjoy_subscriber(component)
"Logjoy::LogSubscribers::#{component.to_s.camelize}".constantize
end
|
.set_customizer(app) ⇒ Object
25
26
27
28
29
|
# File 'lib/logjoy.rb', line 25
def set_customizer(app)
return unless enabled?(app)
self.customizer = app.config.logjoy.customizer
end
|
.set_path_filters(app) ⇒ Object
31
32
33
34
35
|
# File 'lib/logjoy.rb', line 31
def set_path_filters(app)
return unless enabled?(app)
self.filters = app.config.logjoy.filters || []
end
|