Skip to content

Instantly share code, notes, and snippets.

@samnang
Created May 24, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samnang/beffdf85f11a8be70e46 to your computer and use it in GitHub Desktop.
Save samnang/beffdf85f11a8be70e46 to your computer and use it in GitHub Desktop.
Clear logs
# config/initializers/clear_logs.rb
if Rails.env.development?
MAX_LOG_SIZE = 2.megabytes
logs = File.join(Rails.root, 'log', '*.log')
if Dir[logs].any? {|log| File.size?(log).to_i > MAX_LOG_SIZE }
$stdout.puts "Runing rake log:clear"
`rake log:clear`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment