Skip to content

Instantly share code, notes, and snippets.

@leifcr
Forked from pahanix/gist:885671
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save leifcr/9462906 to your computer and use it in GitHub Desktop.
Save leifcr/9462906 to your computer and use it in GitHub Desktop.
# config/initializers/clear_dev_logs.rb
# This snippet simply clears your logs when they are too large.
# Large logs for development are usually something you don't want.
# Every time you run rails server or rails console it checks the size
# of your development logfile and truncates it.
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