Class: Wordmove::Logger
- Inherits:
-
Logger
- Object
- Logger
- Wordmove::Logger
- Defined in:
- lib/wordmove/logger.rb
Constant Summary collapse
- MAX_LINE =
70
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(device, strings_to_hide = []) ⇒ Logger
constructor
A new instance of Logger.
- #plain(message) ⇒ Object
- #success(message) ⇒ Object
- #task(title) ⇒ Object
- #task_step(local_step, title) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(device, strings_to_hide = []) ⇒ Logger
Returns a new instance of Logger.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/wordmove/logger.rb', line 5 def initialize(device, strings_to_hide = []) super(device, formatter: proc { |_severity, _datetime, _progname, | = if strings_to_hide.empty? else .gsub( Regexp.new( strings_to_hide.map { |string| Regexp.escape(string) }.join('|') ), '[secret]' ) end "\n#{}\n" }) end |
Instance Method Details
#debug(message) ⇒ Object
45 46 47 |
# File 'lib/wordmove/logger.rb', line 45 def debug() add(DEBUG, " đ debug".magenta + " | ".black + .to_s) end |
#error(message) ⇒ Object
37 38 39 |
# File 'lib/wordmove/logger.rb', line 37 def error() add(ERROR, " â error".red + " | ".black + .to_s) end |
#info(message) ⇒ Object
53 54 55 |
# File 'lib/wordmove/logger.rb', line 53 def info() add(INFO, " âšī¸ info".yellow + " | ".black + .to_s) end |
#plain(message) ⇒ Object
57 58 59 |
# File 'lib/wordmove/logger.rb', line 57 def plain() add(INFO, .to_s) end |
#success(message) ⇒ Object
41 42 43 |
# File 'lib/wordmove/logger.rb', line 41 def success() add(INFO, " â success".green + " | ".black + .to_s) end |
#task(title) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/wordmove/logger.rb', line 22 def task(title) prefix = "âŦ" * 2 title = " #{title} " padding = "âŦ" * padding_length(title) add(INFO, prefix + title.light_white + padding) end |
#task_step(local_step, title) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/wordmove/logger.rb', line 29 def task_step(local_step, title) if local_step add(INFO, " local".cyan + " | ".black + title.to_s) else add(INFO, " remote".yellow + " | ".black + title.to_s) end end |
#warn(message) ⇒ Object
49 50 51 |
# File 'lib/wordmove/logger.rb', line 49 def warn() add(WARN, " â ī¸ warning".yellow + " | ".black + .to_s) end |