24 lines
1013 B
Ruby
24 lines
1013 B
Ruby
module JamRuby
|
|
class IcecastLogging < ActiveRecord::Base
|
|
|
|
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :logging, :foreign_key => "logging_id"
|
|
has_many :templates, :class_name => "JamRuby::IcecastTemplate", :inverse_of => :logging, :foreign_key => "logging_id"
|
|
|
|
validates :access_log, presence: true
|
|
validates :error_log, presence: true
|
|
validates :log_level, :inclusion => {:in => [1, 2, 3, 4]}
|
|
validates :log_archive, :inclusion => {:in => [nil, true, false]}
|
|
validates :log_size, numericality: {only_integer: true}, if: lambda {|m| m.log_size.present?}
|
|
|
|
def dumpXml(builder)
|
|
builder.tag! 'logging' do |log|
|
|
log.tag! 'accesslog', access_log
|
|
log.tag! 'errorlog', error_log
|
|
log.tag! 'playlistlog', playlist_log if playlist_log
|
|
log.tag! 'logsize', log_size if log_size
|
|
log.tag! 'logarchive', log_archive ? '1' : '0' unless log_archive.nil?
|
|
log.tag! 'loglevel', log_level
|
|
end
|
|
end
|
|
end
|
|
end |