puts override : make sure that the object has a method .gsub before calling it

This commit is contained in:
erwanlr
2013-01-19 15:05:40 +01:00
parent 0b5d7ad147
commit 3f90018dd0

View File

@@ -158,7 +158,9 @@ end
# Override for puts to enable logging
def puts(o = "")
# remove color for logging
if o.respond_to?("gsub")
temp = o.gsub(/\e\[\d+m(.*)?\e\[0m/, '\1')
File.open(LOG_FILE, "a+") { |f| f.puts(temp) }
end
super(o)
end