Class: Logger
- Inherits:
-
Object
- Object
- Logger
- Defined in:
- lib/logger.rb
Overview
The Logger class provides utility methods for printing console logs with different formatting.
Class Method Summary collapse
-
.duplicate(string, duplicate) ⇒ Object
Prints a string and its duplicate.
-
.error(message) ⇒ Object
Prints an error message.
-
.file_not_found(file) ⇒ Object
Prints a file not found error message.
-
.header(text) ⇒ Object
Prints a header.
-
.key_transform(old_key, string) ⇒ Object
Prints a key transfom message.
-
.lost_keys(keys) ⇒ Object
Prints the lost keys.
-
.string(string) ⇒ Object
Prints a string value.
-
.string_value(key, value) ⇒ Object
Prints a string value.
Class Method Details
.duplicate(string, duplicate) ⇒ Object
Prints a string and its duplicate.
26 27 28 |
# File 'lib/logger.rb', line 26 def self.duplicate(string, duplicate) puts "#{Formatter.string(string.key, string.value)} ↔ #{Paint[duplicate.value.to_s, :blue]}" end |
.error(message) ⇒ Object
Prints an error message.
67 68 69 |
# File 'lib/logger.rb', line 67 def self.error() puts Paint["Error: #{}", :red] end |
.file_not_found(file) ⇒ Object
Prints a file not found error message.
50 51 52 |
# File 'lib/logger.rb', line 50 def self.file_not_found(file) puts Paint["#{file} not found", :red] end |
.header(text) ⇒ Object
Prints a header.
41 42 43 44 45 |
# File 'lib/logger.rb', line 41 def self.header(text) puts "=" * text.length puts text puts "=" * text.length end |
.key_transform(old_key, string) ⇒ Object
Prints a key transfom message.
34 35 36 |
# File 'lib/logger.rb', line 34 def self.key_transform(old_key, string) puts "#{Paint[old_key, :red]} → #{Formatter.string(string.key, string.value)}" end |
.lost_keys(keys) ⇒ Object
Prints the lost keys.
57 58 59 60 61 62 |
# File 'lib/logger.rb', line 57 def self.lost_keys(keys) return if keys.empty? puts "Lost keys: #{keys.length}" puts keys.map { |key| Paint[key.to_s, :red] }.join(", ") end |