Skip to content

Instantly share code, notes, and snippets.

@aritode
Forked from krsmurata/clear_logs.rb
Created December 4, 2021 20:42
Show Gist options
  • Save aritode/138807ecdc356cabc48e0683a0fcb5f8 to your computer and use it in GitHub Desktop.
Save aritode/138807ecdc356cabc48e0683a0fcb5f8 to your computer and use it in GitHub Desktop.
Clear development logs
if Rails.env.development?
MAX_LOG_SIZE = 10.megabytes
logs = [ File.join(Rails.root, 'log', 'development.log'), File.join(Rails.root, 'log', 'test.log') ]
logs.each do |log|
log_size = File.size?(log).to_i
if log_size > MAX_LOG_SIZE
$stdout.puts "Removing Log: #{log}"
`rm #{log}`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment