mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
c10a78124c
Same as 4d4ff531b8
23 lines
521 B
Ruby
23 lines
521 B
Ruby
namespace :log do
|
|
desc "Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)"
|
|
task :clear do
|
|
log_files.each do |file|
|
|
clear_log_file(file)
|
|
end
|
|
end
|
|
|
|
def log_files
|
|
if ENV['LOGS']
|
|
ENV['LOGS'].split(',')
|
|
.map { |file| "log/#{file.strip}.log" }
|
|
.select { |file| File.exist?(file) }
|
|
else
|
|
FileList["log/*.log"]
|
|
end
|
|
end
|
|
|
|
def clear_log_file(file)
|
|
f = File.open(file, "w")
|
|
f.close
|
|
end
|
|
end
|