Class: Sfn::Command::Trace
- Inherits:
-
Sfn::Command
- Object
- Bogo::Cli::Command
- Sfn::Command
- Sfn::Command::Trace
- Defined in:
- lib/sfn/command/trace.rb
Overview
Trace command
Constant Summary
Constants included from Sfn::CommandModule::Template
Sfn::CommandModule::Template::DEFAULT_PROVIDER_NAME, Sfn::CommandModule::Template::MAX_PARAMETER_ATTEMPTS, Sfn::CommandModule::Template::TEMPLATE_IGNORE_DIRECTORIES
Constants inherited from Sfn::Command
CONFIG_BASE_NAME, VALID_CONFIG_EXTENSIONS
Instance Method Summary collapse
-
#execute! ⇒ Object
Print the requested template.
Methods included from Sfn::CommandModule::Stack
Methods included from Sfn::CommandModule::Template
Methods included from Sfn::CommandModule::Base
Methods inherited from Sfn::Command
Methods included from Sfn::CommandModule::Callbacks
#api_action!, #callbacks_for, #run_callbacks_for
Constructor Details
This class inherits a constructor from Sfn::Command
Instance Method Details
#execute! ⇒ Object
Print the requested template
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sfn/command/trace.rb', line 13 def execute! config[:sparkle_dump] = true config[:print_only] = true file = load_template_file if !file.is_a?(SparkleFormation) raise "Cannot trace non-SparkleFormation template" else writer = proc do |audit_log, indent = ""| audit_log.each do |record| header = "#{indent}-> " header << ui.color(record.type.to_s.capitalize, :bold) header << " - #{record.name}" source = "#{indent} | source: " if record.location.line > 0 source << "#{record.location.path} @ #{record.location.line}" else source << ui.color(record.location.path, :yellow) end origin = "#{indent} | caller: " if record.caller.line > 0 origin << "#{record.caller.path} @ #{record.caller.line}" else origin << ui.color(record.caller.path, :yellow) end duration = "#{indent} | duration: " if record.compile_duration duration << Kernel.sprintf("%0.4f", record.compile_duration) duration << "s" else duration < "N/A" end ui.info header ui.info source ui.info origin ui.info duration if record.audit_log.count > 0 writer.call(record.audit_log, indent + " |") end end end ui.info ui.color("Trace information:", :bold) writer.call(file.audit_log) end end |