Class: EC2Ctl::Logger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ec2ctl/logger.rb

Constant Summary collapse

InvalidOutputFormat =
Class.new RuntimeError
VALID_FORMATS =
%w(json yaml table markdown backlog)

Instance Method Summary collapse

Constructor Details

#initialize(output_format: :json, null_output: false, pretty: false, verbose: false, std_io: STDOUT, err_io: STDERR) ⇒ Logger

Returns a new instance of Logger.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ec2ctl/logger.rb', line 12

def initialize(
  output_format: :json,
  null_output:   false,
  pretty:        false,
  verbose:       false,
  std_io:        STDOUT,
  err_io:        STDERR
)
  @output_format = output_format
  @null_output   = null_output
  @std_logger    = ::Logger.new std_io
  @err_logger    = ::Logger.new err_io

  @std_logger.level = verbose ? ::Logger::DEBUG : ::Logger::INFO
  @err_logger.level = verbose ? ::Logger::DEBUG : ::Logger::INFO

  @std_logger.formatter = formatter(std_io, pretty)
  @err_logger.formatter = formatter(err_io, pretty)

  self
end