Module: Dapp::Dimg::Build::Stage::Mod::Logging
- Included in:
- Base
- Defined in:
- lib/dapp/dimg/build/stage/mod/logging.rb
Instance Method Summary collapse
- #ignore_log_commands? ⇒ Boolean
- #image_should_be_introspected? ⇒ Boolean
- #image_should_be_introspected_after_build? ⇒ Boolean
- #image_should_be_introspected_before_build? ⇒ Boolean
- #log_build ⇒ Object
- #log_image_build ⇒ 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_not_be_detailed? ⇒ Boolean
Instance Method Details
#ignore_log_commands? ⇒ Boolean
75 76 77 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 75 def ignore_log_commands? false end |
#image_should_be_introspected? ⇒ Boolean
83 84 85 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 83 def image_should_be_introspected? image_should_be_introspected_after_build? || image_should_be_introspected_before_build? end |
#image_should_be_introspected_after_build? ⇒ Boolean
91 92 93 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 91 def image_should_be_introspected_after_build? dimg.stage_should_be_introspected_after_build?(name) && !dimg.dapp.dry_run? end |
#image_should_be_introspected_before_build? ⇒ Boolean
87 88 89 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 87 def image_should_be_introspected_before_build? dimg.stage_should_be_introspected_before_build?(name) && !dimg.dapp.dry_run? end |
#log_build ⇒ Object
19 20 21 22 23 24 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 19 def log_build dimg.dapp.with_log_indent do dimg.dapp.log_info dimg.dapp.t(code: 'image.signature', data: { signature: image_name }) log_image_details unless empty? end end |
#log_image_build ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 7 def log_image_build case when dimg.dapp.dry_run? && image_should_be_untagged? then log_state(:rebuild, styles: { status: :success }) when image.built? then log_state(:using_cache) when should_be_not_present? then log_state(:not_present) when dimg.dapp.dry_run? then log_state(:build, styles: { status: :success }) else yield end ensure log_build end |
#log_image_commands ⇒ Object
57 58 59 60 61 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 57 def log_image_commands return if (bash_commands = image.send(:bash_commands)).empty? dimg.dapp.log_info dimg.dapp.t(code: 'image.commands') dimg.dapp.with_log_indent { dimg.dapp.log_info bash_commands.join("\n") } end |
#log_image_created_at ⇒ Object
41 42 43 44 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 41 def log_image_created_at dimg.dapp.log_info dimg.dapp.t(code: 'image.info.created_at', data: { value: Time.parse(image.created_at).localtime }) end |
#log_image_details ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 26 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
35 36 37 38 39 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 35 def log_image_instructions return if (instructions = image.prepare_instructions(image.send(:change_options))).empty? dimg.dapp.log_info dimg.dapp.t(code: 'image.instructions') dimg.dapp.with_log_indent { dimg.dapp.log_info instructions.join("\n") } end |
#log_image_size ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 46 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.dapp.log_info dimg.dapp.t(code: code, data: { mb: (bytes / 1000 / 1000).round(3) }) end |
#log_name ⇒ Object
63 64 65 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 63 def log_name dimg.dapp.t(code: name, context: log_name_context) end |
#log_name_context ⇒ Object
67 68 69 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 67 def log_name_context :stage end |
#log_state(state_code, styles: {}) ⇒ Object
71 72 73 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 71 def log_state(state_code, styles: {}) dimg.dapp.log_state(log_name, state: dimg.dapp.t(code: state_code, context: 'state'), styles: styles) end |
#should_not_be_detailed? ⇒ Boolean
79 80 81 |
# File 'lib/dapp/dimg/build/stage/mod/logging.rb', line 79 def should_not_be_detailed? image.send(:bash_commands).empty? end |