Module: EffectiveLogging
- Includes:
- EffectiveGem
- Defined in:
- lib/effective_logging.rb,
lib/effective_logging/engine.rb,
lib/effective_logging/version.rb,
lib/effective_logging/user_logger.rb,
lib/effective_logging/email_logger.rb,
lib/effective_logging/log_page_views.rb,
lib/effective_logging/set_current_user.rb,
lib/effective_logging/active_record_logger.rb,
lib/effective_logging/active_storage_logger.rb,
lib/generators/effective_logging/install_generator.rb
Defined Under Namespace
Modules: ActiveStorageLogger, Generators, LogPageViews, SetCurrentUser
Classes: ActiveRecordLogger, EmailLogger, Engine, UserLogger
Constant Summary
collapse
- VERSION =
'4.4.3'.freeze
Class Method Summary
collapse
Class Method Details
.active_storage_excepts ⇒ Object
77
78
79
80
81
|
# File 'lib/effective_logging.rb', line 77
def self.active_storage_excepts
excepts = Array(active_storage_except) - [nil, '', ' ']
raise("effective_logging.active_storage_except should be an Array of Strings") if excepts.present? && !excepts.all? { |type| type.kind_of?(String) }
excepts
end
|
.active_storage_onlies ⇒ Object
71
72
73
74
75
|
# File 'lib/effective_logging.rb', line 71
def self.active_storage_onlies
onlies = Array(active_storage_only) - [nil, '', ' ']
raise("effective_logging.active_storage_only should be an Array of Strings") if onlies.present? && !onlies.all? { |type| type.kind_of?(String) }
onlies
end
|
.config_keys ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/effective_logging.rb', line 6
def self.config_keys
[
:logs_table_name, :tracks_table_name, :layout, :additional_statuses,
:log_class_name,
:active_storage_enabled, :active_storage_only, :active_storage_except,
:email_enabled, :sign_in_enabled, :sign_out_enabled
]
end
|
.current_user ⇒ Object
50
51
52
|
# File 'lib/effective_logging.rb', line 50
def self.current_user
Thread.current[:effective_logging_current_user]
end
|
.current_user=(user) ⇒ Object
This is set by the “set_effective_logging_current_user” before_filter.
46
47
48
|
# File 'lib/effective_logging.rb', line 46
def self.current_user=(user)
Thread.current[:effective_logging_current_user] = user
end
|
.Log ⇒ Object
17
18
19
|
# File 'lib/effective_logging.rb', line 17
def self.Log
log_class_name&.constantize || Effective::Log
end
|
.log_changes_status ⇒ Object
41
42
43
|
# File 'lib/effective_logging.rb', line 41
def self.log_changes_status
'change'.freeze
end
|
.statuses ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/effective_logging.rb', line 21
def self.statuses
@statuses ||= (
base = [
'info',
'success',
'error',
'view',
log_changes_status, ('download' if active_storage_enabled),
('email' if email_enabled),
('sign_in' if sign_in_enabled),
('sign_out' if sign_out_enabled)
].compact
additional = Array(additional_statuses).map { |status| status.to_s.downcase }
base | additional )
end
|
.supressed(&block) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/effective_logging.rb', line 59
def self.supressed(&block)
Thread.current[:effective_logging_supressed] = true
value = yield
Thread.current[:effective_logging_supressed] = nil
value
end
|
.supressed=(value) ⇒ Object
Used to supress all logging
55
56
57
|
# File 'lib/effective_logging.rb', line 55
def self.supressed=(value)
Thread.current[:effective_logging_supressed] = value
end
|
.supressed? ⇒ Boolean
66
67
68
|
# File 'lib/effective_logging.rb', line 66
def self.supressed?
Thread.current[:effective_logging_supressed] == true
end
|