Module: Clerk::Logger

Extended by:
ActiveSupport::Concern
Defined in:
lib/clerk/logger.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#included_fieldsObject



34
35
36
37
38
39
40
# File 'lib/clerk/logger.rb', line 34

def included_fields
  {}.tap do |return_hash|
    self.class.default_fields.each do |source_field, target_field|
      return_hash[target_field.to_sym] = read_attribute(source_field.to_sym)
    end
  end
end

#log(msg, level = :info) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/clerk/logger.rb', line 25

def log(msg, level = :info)
  log_items.create!(
    included_fields.merge(
      :message => msg,
      :level => level
    )
  )
end