socialforge/app/helpers/logger_helper.rb

28 lines
742 B
Ruby
Raw Normal View History

module LoggerHelper
#输出日志
def OutLogger
#日志输出级别
#Rails.logger.level = Logger::INFO
if(!File.exist?("database"))
Dir.mkdir("database")
end
if(!File.exist?("database/get"))
Dir.mkdir("database/get")
end
if(!File.exist?("database/sql"))
Dir.mkdir("database/sql")
end
if(!File.exist?("database/controller"))
Dir.mkdir("database/controller")
end
Rails.logger = Logger.new("database/get/#{Date.today.to_s}.log", "daily")
ActiveRecord::Base.logger = Logger.new("database/sql/#{Date.today.to_s}.log", "daily")
ActionController::Base.logger = Logger.new("database/controller/#{Date.today.to_s}.log", "daily")
end
end