Skip to content

Instantly share code, notes, and snippets.

@serra-allgood
Created July 18, 2014 16:32
Show Gist options
  • Save serra-allgood/9343f72ffad62e3550d2 to your computer and use it in GitHub Desktop.
Save serra-allgood/9343f72ffad62e3550d2 to your computer and use it in GitHub Desktop.
Truncates development.log if it's larger than 1 MB
# Cool little gist obtained from Leif Ringstad at his blog bitelem.com
if Rails.env.development?
MAX_LOG_SIZE = 1.megabytes
DEV_LOG_FILE = File.join(Rails.root, "log", "development.log")
if File.size?(DEV_LOG_FILE).to_i > MAX_LOG_SIZE
$stdout.puts "-----------------------------------------------------"
$stdout.puts "Truncating development.log..."
$stdout.puts "-----------------------------------------------------"
File.truncate(DEV_LOG_FILE, 0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment