Class: Kitchen::Command::Logs

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/command/logs.rb

Overview

Command to print structured logs for one instance.

Constant Summary collapse

LEVELS =
%w{debug info warn error fatal unknown}.freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Constructor Details

This class inherits a constructor from Kitchen::Command::Base

Instance Method Details

#callObject

Invoke the command.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kitchen/command/logs.rb', line 25

def call
  validate_format!
  validate_level!
  if options[:all_sessions]
    emit_all_session_logs
    return
  end

  target_instances = instances
  validate_follow_target!(target_instances)

  target_instances.each do |instance|
    session_id = selected_session_id(instance)
    die "No structured log file found at #{instance.structured_log_path}" unless
      File.file?(instance.structured_log_path)

    emit_file(instance.structured_log_path, session_id)
    follow_file(instance.structured_log_path, session_id) if options[:follow]
  end
end