Class: Meteorlog::Wrapper::LogGroupCollection

Inherits:
Object
  • Object
show all
Includes:
Logger::Helper
Defined in:
lib/meteorlog/wrapper/log_group_collection.rb

Instance Method Summary collapse

Methods included from Logger::Helper

#log

Constructor Details

#initialize(cloud_watch_logs, log_groups, options = {}) ⇒ LogGroupCollection

Returns a new instance of LogGroupCollection.



4
5
6
7
8
# File 'lib/meteorlog/wrapper/log_group_collection.rb', line 4

def initialize(cloud_watch_logs, log_groups, options = {})
  @cloud_watch_logs = cloud_watch_logs
  @log_groups = log_groups
  @options = options
end

Instance Method Details

#create(name, opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/meteorlog/wrapper/log_group_collection.rb', line 17

def create(name, opts = {})
  log(:info, 'Create LogGroup', :cyan, name)

  unless @options[:dry_run]
    @cloud_watch_logs.create_log_group(:log_group_name => name)
    @options[:modified] = true
  end

  log_group = OpenStruct.new(
    :log_group_name => name, :log_streams => [], :metric_filters => [])

  Meteorlog::Wrapper::LogGroup.new(
    @cloud_watch_logs, log_group, @options)
end

#eachObject



10
11
12
13
14
15
# File 'lib/meteorlog/wrapper/log_group_collection.rb', line 10

def each
  @log_groups.each do |log_group|
    yield(Meteorlog::Wrapper::LogGroup.new(
      @cloud_watch_logs, log_group, @options))
  end
end