Class: MagicLogger
- Inherits:
-
Object
- Object
- MagicLogger
- Defined in:
- lib/magic_logger/magic_logger.rb
Class Attribute Summary collapse
-
.formatted ⇒ Object
Returns the value of attribute formatted.
-
.raw ⇒ Object
Returns the value of attribute raw.
Class Method Summary collapse
- .clear ⇒ Object
- .format_array(array) ⇒ Object
- .format_hash(hash) ⇒ Object
- .log(title, value) ⇒ Object
- .pretty_text ⇒ Object
- .process ⇒ Object
Class Attribute Details
.formatted ⇒ Object
Returns the value of attribute formatted.
9 10 11 |
# File 'lib/magic_logger/magic_logger.rb', line 9 def formatted @formatted end |
.raw ⇒ Object
Returns the value of attribute raw.
9 10 11 |
# File 'lib/magic_logger/magic_logger.rb', line 9 def raw @raw end |
Class Method Details
.clear ⇒ Object
21 22 23 |
# File 'lib/magic_logger/magic_logger.rb', line 21 def clear @raw.clear end |
.format_array(array) ⇒ Object
39 40 41 |
# File 'lib/magic_logger/magic_logger.rb', line 39 def format_array(array) array.join("\n ") end |
.format_hash(hash) ⇒ Object
35 36 37 |
# File 'lib/magic_logger/magic_logger.rb', line 35 def format_hash(hash) hash.map { |k, v| "#{k}: #{v}" }.join("\n ") end |
.log(title, value) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/magic_logger/magic_logger.rb', line 11 def log(title, value) safe_value = value.clone entry = case safe_value when Hash then format_hash(safe_value) when Array then format_array(safe_value) else safe_value end @raw.key?(title) ? @raw[title] << "\n #{entry}" : @raw[title] = entry.to_s end |
.pretty_text ⇒ Object
25 26 27 |
# File 'lib/magic_logger/magic_logger.rb', line 25 def pretty_text @raw.map { |k, v| "\n#{k}:\n #{v}" }.join("\n") end |
.process ⇒ Object
29 30 31 32 |
# File 'lib/magic_logger/magic_logger.rb', line 29 def process warn "[DEPRECATION] `process` is deprecated. Please use `pretty_text` instead. " pretty_text end |