Sha256: 912d410c4cb0741e2929d6ff0417a21c8b7e9f1319d9d0dd7bcffab5dc19fe69

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

require 'effective_resources'
require 'effective_logging/engine'
require 'effective_logging/version'

module EffectiveLogging
  mattr_accessor :supressed

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

  include EffectiveGem

  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_in_enabled),
        ('sign_out' if sign_out_enabled)
      ].compact

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

      base | additional # union
    )
  end

  def self.log_changes_status
    'change'.freeze
  end

  # This is set by the "set_effective_logging_current_user" before_filter.
  def self.current_user=(user)
    Thread.current[:effective_logging_current_user] = user
  end

  def self.current_user
    Thread.current[:effective_logging_current_user]
  end

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

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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
effective_logging-3.1.7 lib/effective_logging.rb
effective_logging-3.1.6 lib/effective_logging.rb
effective_logging-3.1.5 lib/effective_logging.rb
effective_logging-3.1.4 lib/effective_logging.rb
effective_logging-3.1.3 lib/effective_logging.rb
effective_logging-3.1.2 lib/effective_logging.rb
effective_logging-3.1.1 lib/effective_logging.rb
effective_logging-3.1.0 lib/effective_logging.rb