Module: Dapp::Dapp::Logging::Process
- Included in:
- Dapp::Dapp
- Defined in:
- lib/dapp/dapp/logging/process.rb
Constant Summary collapse
- DEFAULT_TERMINAL_WIDTH =
120
- 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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dapp/dapp/logging/process.rb', line 28 def log_process(, process: nil, short: false, quiet: false, style: {}, status: {}, &blk) 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 quiet log_process_quiet(.to_s, style: style, status: status, &blk) elsif short log_process_short(.to_s, style: style, status: status, &blk) else process ||= t(code: 'status.process.default') log_process_verbose(.to_s, process: process, style: style, status: status, &blk) end end |
#log_secondary_process(message, **kwargs, &blk) ⇒ Object
rubocop:enable Metrics/ParameterLists
48 49 50 |
# File 'lib/dapp/dapp/logging/process.rb', line 48 def log_secondary_process(, **kwargs, &blk) log_process(, **kwargs.merge(style: { message: :secondary, success: :secondary }), &blk) end |
#log_state(message, state:, styles: {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dapp/dapp/logging/process.rb', line 15 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 |