Module: Logifyer::Common
- Included in:
- Ruby::JSONFormatter::Base
- Defined in:
- lib/logifyer/common.rb
Defined Under Namespace
Modules: JSON
Constant Summary collapse
- ANSI_ESCAPE_REGEX =
/\e\[\d+(;\d+)*m/.freeze
Instance Method Summary collapse
Instance Method Details
#current_time(time) ⇒ Object
17 18 19 20 |
# File 'lib/logifyer/common.rb', line 17 def current_time(time) return time if time Time.respond_to?(:current) ? Time.current : Time.now end |
#msg2str(msg) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/logifyer/common.rb', line 4 def msg2str(msg) case msg when ::String clean_msg = remove_ansi_escape_codes(msg) clean_msg.gsub("\n", " | ") when ::Exception "#{remove_ansi_escape_codes(msg.)} (#{msg.class}) | " << (msg.backtrace || []).map { |line| remove_ansi_escape_codes(line) }.join(" | ") else remove_ansi_escape_codes(msg.inspect) end end |