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 =
'3.2.0'.freeze

Class Method Summary collapse

Class Method Details

.config_keysObject


6
7
8
9
10
11
# File 'lib/effective_logging.rb', line 6

def self.config_keys
  [
    :logs_table_name, :layout, :additional_statuses,
    :active_storage_enabled, :email_enabled, :sign_in_enabled, :sign_out_enabled
  ]
end

.current_userObject


44
45
46
# File 'lib/effective_logging.rb', line 44

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.


40
41
42
# File 'lib/effective_logging.rb', line 40

def self.current_user=(user)
  Thread.current[:effective_logging_current_user] = user
end

.log_changes_statusObject


35
36
37
# File 'lib/effective_logging.rb', line 35

def self.log_changes_status
  'change'.freeze
end

.statusesObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/effective_logging.rb', line 15

def self.statuses
  @statuses ||= (
    base = [
      'info',
      'success',
      'error',
      'view',
      log_changes_status, # 'change'
      ('download' if active_storage_enabled),
      ('email' if email_enabled),
      ('sign_in' if ),
      ('sign_out' if sign_out_enabled)
    ].compact

    additional = Array(additional_statuses).map { |status| status.to_s.downcase }

    base | additional # union
  )
end

.supressed(&block) ⇒ Object


53
54
55
56
57
# File 'lib/effective_logging.rb', line 53

def self.supressed(&block)
  Thread.current[:effective_logging_supressed] = true
  yield
  Thread.current[:effective_logging_supressed] = nil
end

.supressed=(value) ⇒ Object

Used to supress all logging


49
50
51
# File 'lib/effective_logging.rb', line 49

def self.supressed=(value)
  Thread.current[:effective_logging_supressed] = value
end

.supressed?Boolean

Returns:

  • (Boolean)

59
60
61
# File 'lib/effective_logging.rb', line 59

def self.supressed?
  Thread.current[:effective_logging_supressed] == true
end