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 21 |
# 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? || ENV.fetch('WORDMOVE_REVEAL_SECRETS', nil).present? else .gsub( Regexp.new( strings_to_hide.map { |string| Regexp.escape(string) }.join('|') ), '[secret]' ) end "\n#{}\n" }) end |
Instance Method Details
#debug(message) ⇒ Object
46 47 48 |
# File 'lib/wordmove/logger.rb', line 46 def debug() add(DEBUG, ' 🛠 debug'.magenta + ' | '.black + .to_s) end |
#error(message) ⇒ Object
38 39 40 |
# File 'lib/wordmove/logger.rb', line 38 def error() add(ERROR, ' ❌ error'.red + ' | '.black + .to_s) end |
#info(message) ⇒ Object
54 55 56 |
# File 'lib/wordmove/logger.rb', line 54 def info() add(INFO, ' ℹ️ info'.yellow + ' | '.black + .to_s) end |
#plain(message) ⇒ Object
58 59 60 |
# File 'lib/wordmove/logger.rb', line 58 def plain() add(INFO, .to_s) end |
#success(message) ⇒ Object
42 43 44 |
# File 'lib/wordmove/logger.rb', line 42 def success() add(INFO, ' ✅ success'.green + ' | '.black + .to_s) end |
#task(title) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/wordmove/logger.rb', line 23 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
30 31 32 33 34 35 36 |
# File 'lib/wordmove/logger.rb', line 30 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
50 51 52 |
# File 'lib/wordmove/logger.rb', line 50 def warn() add(WARN, ' ⚠️ warning'.yellow + ' | '.black + .to_s) end |