Skip to content
Browse files

much nicer with colors and number formatting

  • Loading branch information...
1 parent 6bcf307 commit 3187ad15332ab00ae55a9cf2355070bc49ae21b0 @binarylogic committed Mar 1, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/memorylogic.rb
View
12 lib/memorylogic.rb
@@ -5,8 +5,12 @@ def self.included(klass)
end
end
+ class << self
+ include ActionView::Helpers::NumberHelper
+ end
+
def self.memory_usage
- `ps -o rss= -p #{Process.pid}`.to_i
+ number_to_human_size(`ps -o rss= -p #{Process.pid}`.to_i)
end
private
@@ -19,9 +23,9 @@ def log_memory_usage
ActiveSupport::BufferedLogger.class_eval do
def add_with_memory_info(severity, message = nil, progname = nil, &block)
- message ||= ""
- message += "\nMemory usage: #{Memorylogic.memory_usage}\n\n"
- add_without_memory_info(severity, message, progname, &block)
+ r = add_without_memory_info(severity, message, progname, &block)
+ add_without_memory_info(severity, " \e[1;31mMemory usage:\e[0m #{Memorylogic.memory_usage}\n\n", progname, &block)
+ r
end
alias_method_chain :add, :memory_info

0 comments on commit 3187ad1

Please sign in to comment.
Something went wrong with that request. Please try again.