Module: Dapp::Project::Logging::Process
- Included in:
- Dapp::Project
- Defined in:
- lib/dapp/project/logging/process.rb
Overview
Process
Constant Summary collapse
- DEFAULT_STYLE =
{ message: :step, process: :secondary, status: :secondary, success: :success, failed: :warning, time: :default }.freeze
Instance Method Summary collapse
-
#log_process(message, process: nil, short: false, quiet: false, style: {}, status: {}, &blk) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#log_secondary_process(message, **kwargs, &blk) ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #log_state(message, state:, styles: {}) ⇒ Object
Instance Method Details
#log_process(message, process: nil, short: false, quiet: false, style: {}, status: {}, &blk) ⇒ Object
rubocop:disable Metrics/ParameterLists
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dapp/project/logging/process.rb', line 30 def log_process(, process: nil, short: false, quiet: false, style: {}, status: {}, &blk) return yield if quiet style[:message] ||= DEFAULT_STYLE[:message] style[:process] ||= DEFAULT_STYLE[:process] style[:failed] ||= DEFAULT_STYLE[:failed] style[:success] ||= DEFAULT_STYLE[:success] status[:success] ||= t(code: 'status.success.default') status[:failed] ||= t(code: 'status.failed.default') if log_verbose? && !short process ||= t(code: 'status.process.default') log_process_verbose(.to_s, process: process, style: style, status: status, &blk) else log_process_short(.to_s, style: style, status: status, &blk) end end |
#log_secondary_process(message, **kwargs, &blk) ⇒ Object
rubocop:enable Metrics/ParameterLists
50 51 52 |
# File 'lib/dapp/project/logging/process.rb', line 50 def log_secondary_process(, **kwargs, &blk) log_process(, **kwargs.merge(style: { message: :secondary, success: :secondary }, quiet: !log_verbose?), &blk) end |
#log_state(message, state:, styles: {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dapp/project/logging/process.rb', line 17 def log_state(, state:, styles: {}) styles[:message] ||= DEFAULT_STYLE[:message] styles[:status] ||= DEFAULT_STYLE[:status] = slice() state = rjust(state, ) = paint_string(, styles[:message]) formatted_status = paint_string(state, styles[:status]) log "#{}#{formatted_status}" end |