aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/tasks/log.rake
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-09-10 10:43:09 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-10-14 08:52:35 +0900
commit447e1a48811fa053e8bef954376d1ad47bdb5cef (patch)
tree1f0b7c44ce772b2ea85095aa8580513b8f18b01f /railties/lib/rails/tasks/log.rake
parente10e3c7da215ef848db7592068993f14aac00fa6 (diff)
downloadrails-447e1a48811fa053e8bef954376d1ad47bdb5cef.tar.gz
rails-447e1a48811fa053e8bef954376d1ad47bdb5cef.tar.bz2
rails-447e1a48811fa053e8bef954376d1ad47bdb5cef.zip
clear all environments log files by default
In #22703, `log:clear` task has been changed to clear only standard environment log files. However, it is often to add a non-standard environment(e.g. "staging"). Therefore, I think than it is better to clear all environments log files by default.
Diffstat (limited to 'railties/lib/rails/tasks/log.rake')
-rw-r--r--railties/lib/rails/tasks/log.rake8
1 files changed, 6 insertions, 2 deletions
diff --git a/railties/lib/rails/tasks/log.rake b/railties/lib/rails/tasks/log.rake
index c376234fee..ba796845d7 100644
--- a/railties/lib/rails/tasks/log.rake
+++ b/railties/lib/rails/tasks/log.rake
@@ -3,7 +3,7 @@ namespace :log do
##
# Truncates all/specified log files
# ENV['LOGS']
- # - defaults to standard environment log files i.e. 'development,test,production'
+ # - defaults to all environments log files i.e. 'development,test,production'
# - ENV['LOGS']=all truncates all files i.e. log/*.log
# - ENV['LOGS']='test,development' truncates only specified files
desc "Truncates all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)"
@@ -19,7 +19,7 @@ namespace :log do
elsif ENV["LOGS"]
log_files_to_truncate(ENV["LOGS"])
else
- log_files_to_truncate("development,test,production")
+ log_files_to_truncate(all_environments.join(","))
end
end
@@ -33,4 +33,8 @@ namespace :log do
f = File.open(file, "w")
f.close
end
+
+ def all_environments
+ Dir["config/environments/*.rb"].map { |fname| File.basename(fname, ".*") }
+ end
end