Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
5a14798290
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
|
|
@ -13,3 +13,16 @@ end
|
|||
|
||||
# Initialize the rails application
|
||||
RedmineApp::Application.initialize!
|
||||
|
||||
#日志格式
|
||||
class Logger
|
||||
def format_message(level, time, progname, msg)
|
||||
"#{time.to_s(:db)} #{level} -- #{msg}\r\n"
|
||||
end
|
||||
end
|
||||
|
||||
#输出日志(database文件夹下get、sql、controller按照日期 分别输出路由信息、SQL语句、调用页面)[影响系统效率使用完请注释掉]
|
||||
#include LoggerHelper
|
||||
#LoggerHelper.OutLogger
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue