Created
December 9, 2018 22:10
-
-
Save david-pm/74ca9e1f75f0c751bc66671c001459ed to your computer and use it in GitHub Desktop.
clear dev logs on app boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return unless 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 "---------- \033[32m clearing dev logs \033[0m --------------" | |
`rails log:clear` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
throw this under config/initializers/clear_logs.rb