Module: Dapp::Build::Stage::Mod::Logging
- Included in:
- Base
- Defined in:
- lib/dapp/build/stage/mod/logging.rb
Overview
Logging
Instance Method Summary collapse
- #ignore_log_commands? ⇒ Boolean
- #log_build ⇒ Object
- #log_image_build(&image_build) ⇒ Object
- #log_image_build_process ⇒ Object
- #log_image_commands ⇒ Object
- #log_image_created_at ⇒ Object
- #log_image_details ⇒ Object
- #log_image_instructions ⇒ Object
- #log_image_size ⇒ Object
- #log_name ⇒ Object
- #log_name_context ⇒ Object
- #log_state(state_code, styles: {}) ⇒ Object
- #should_be_introspected? ⇒ Boolean
- #should_be_quiet? ⇒ Boolean
- #should_not_be_detailed? ⇒ Boolean
Instance Method Details
#ignore_log_commands? ⇒ Boolean
84 85 86 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 84 def ignore_log_commands? false end |
#log_build ⇒ Object
18 19 20 21 22 23 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 18 def log_build dimg.project.with_log_indent do dimg.project.log_info dimg.project.t(code: 'image.signature', data: { signature: image_name }) log_image_details unless empty? end if dimg.project.log_verbose? && !should_be_quiet? end |
#log_image_build(&image_build) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 8 def log_image_build(&image_build) if empty? then log_state(:empty) elsif image.tagged? then log_state(:using_cache) elsif dimg.project.dry_run? then log_state(:build, styles: { status: :success }) else log_image_build_process(&image_build) end ensure log_build end |
#log_image_build_process ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 76 def log_image_build_process return yield if should_be_quiet? dimg.project.log_process(log_name, process: dimg.project.t(code: 'status.process.building'), short: should_not_be_detailed?) do yield end end |
#log_image_commands ⇒ Object
56 57 58 59 60 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 56 def log_image_commands return if (bash_commands = image.send(:bash_commands)).empty? dimg.project.log_info dimg.project.t(code: 'image.commands') dimg.project.with_log_indent { dimg.project.log_info bash_commands.join("\n") } end |
#log_image_created_at ⇒ Object
40 41 42 43 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 40 def log_image_created_at dimg.project.log_info dimg.project.t(code: 'image.info.created_at', data: { value: Time.parse(image.created_at).localtime }) end |
#log_image_details ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 25 def log_image_details if image.tagged? log_image_created_at log_image_size end log_image_commands unless ignore_log_commands? log_image_instructions end |
#log_image_instructions ⇒ Object
34 35 36 37 38 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 34 def log_image_instructions return if (instructions = image.prepare_instructions(image.send(:change_options))).empty? dimg.project.log_info dimg.project.t(code: 'image.instructions') dimg.project.with_log_indent { dimg.project.log_info instructions.join("\n") } end |
#log_image_size ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 45 def log_image_size if !prev_stage.nil? && from_image.tagged? bytes = image.size - from_image.size code = 'image.info.difference' else bytes = image.size code = 'image.info.mb_size' end dimg.project.log_info dimg.project.t(code: code, data: { mb: (bytes / 1000 / 1000).round(3) }) end |
#log_name ⇒ Object
62 63 64 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 62 def log_name dimg.project.t(code: name, context: log_name_context) end |
#log_name_context ⇒ Object
66 67 68 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 66 def log_name_context :stage end |
#log_state(state_code, styles: {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 70 def log_state(state_code, styles: {}) dimg.project.log_state(log_name, state: dimg.project.t(code: state_code, context: 'state'), styles: styles) unless should_be_quiet? end |
#should_be_introspected? ⇒ Boolean
92 93 94 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 92 def should_be_introspected? dimg.project.[:introspect_stage] == name && !dimg.project.dry_run? && !dimg.artifact? end |
#should_be_quiet? ⇒ Boolean
96 97 98 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 96 def should_be_quiet? dimg.artifact? && !dimg.project.log_verbose? end |
#should_not_be_detailed? ⇒ Boolean
88 89 90 |
# File 'lib/dapp/build/stage/mod/logging.rb', line 88 def should_not_be_detailed? image.send(:bash_commands).empty? end |