Class: Log

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/log.rb

Constant Summary collapse

LEVELS =
[:debug, :info, :notice, :warning, :err, :alert, :emerg, :crit]

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object


21
22
23
# File 'app/models/log.rb', line 21

def as_json(options={})
  {:log => {:messages => message, :sources => source}}
end

#levelObject


17
18
19
# File 'app/models/log.rb', line 17

def level
  LEVELS[level_id]
end

#level=(l) ⇒ Object


13
14
15
# File 'app/models/log.rb', line 13

def level= l
  write_attribute(:level_id, LEVELS.index(l))
end

#to_sObject


9
10
11
# File 'app/models/log.rb', line 9

def to_s
  "#{source} #{message}"
end