Method: Fluent::SwiftOutput#configure

Defined in:
lib/fluent/plugin/out_swift.rb

#configure(conf) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fluent/plugin/out_swift.rb', line 48

def configure(conf)
  super

  if format_json = conf['format_json']
    @format_json = true
  else
    @format_json = false
  end

  @ext, @mime_type = case @store_as
    when 'gzip' then ['gz', 'application/x-gzip']
    when 'lzo' then
      begin
        Open3.capture3('lzop -V')
      rescue Errno::ENOENT
        raise ConfigError, "'lzop' utility must be in PATH for LZO compression"
      end
      ['lzo', 'application/x-lzop']
    when 'json' then ['json', 'application/json']
    else ['txt', 'text/plain']
  end

  @timef = TimeFormatter.new(@time_format, @localtime)

  if @localtime
    @path_slicer = Proc.new {|path|
      Time.now.strftime(path)
    }
  else
    @path_slicer = Proc.new {|path|
      Time.now.utc.strftime(path)
    }
  end
end