Clear Development Logs
        Automatically clear development logs when they get over 2mb.
      
      Used 61 times
        
          D
          Dale Zak
        
      Usage
Inspired from https://gist.github.com/krsmurata/1836248.
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/VZgs77"Template Source
Review the code before running this template on your machine.
file 'config/initializers/clear_logs.rb', <<-CODE
if Rails.env.development?
  MAX_LOG_SIZE = 2.megabytes
  logs = Dir[File.join(Rails.root, 'log', '*.log')]
  logs.each do |log|
    log_size = File.size?(log).to_i
    if log_size > MAX_LOG_SIZE
      puts "Removing Log: \#{log}"
      `rm \#{log}`
    end
  end
end
CODE