Class: Ufo::Logs
Instance Method Summary collapse
Methods included from AwsService
#cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb
Methods inherited from Base
#full_service, #info, #initialize, #no_service_message, #switch_current
Methods included from Stack::Helper
#adjust_stack_name, #find_stack, #status
Methods included from Settings
Methods included from Util
#default_cluster, #display_params, #execute, #pretty_time, #settings, #task_definition_arns, #user_params
Constructor Details
This class inherits a constructor from Ufo::Base
Instance Method Details
#cloudwatch_tail(log = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ufo/logs.rb', line 43 def cloudwatch_tail(log={}) o = { log_group_name: log["awslogs-group"], log_stream_name_prefix: log["awslogs-stream-prefix"], since: @options[:since] || "10m", # by default, search only 10 mins in the past follow: @options[:follow], format: @options[:format], } o[:filter_pattern] = @options[:filter_pattern] if @options[:filter_pattern] cw_tail = AwsLogs::Tail.new(o) cw_tail.run end |
#find_log_group_name ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ufo/logs.rb', line 19 def find_log_group_name resp = ecs.describe_task_definition(task_definition: info.service.task_definition) container_definitions = resp.task_definition.container_definitions unless container_definitions.size == 1 puts "ERROR: ufo logs command only supports 1 container definition in the ECS task definition".color(:red) return end definition = container_definitions.first log_conf = definition.log_configuration if log_conf && log_conf.log_driver == "awslogs" # options["awslogs-group"] # options["awslogs-region"] # options["awslogs-stream-prefix"] log_conf. else puts "Only supports awslogs driver. Detected log_driver: #{log_conf.log_driver}" return end end |
#run ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ufo/logs.rb', line 9 def run log = find_log_group_name puts "Showing logs for log group: #{log["awslogs-group"]} and stream prefix #{log["awslogs-stream-prefix"]}" if log cloudwatch_tail(log) else puts "Unable to find log group for service: #{service.service_name}" end end |