class Fluent::Compat::TimeSlicedOutput

Constants

BUFFER_PARAMS

Attributes

localtime[RW]

Private Class Methods

new() click to toggle source
Calls superclass method Fluent::Plugin::Output.new
# File lib/fluent/compat/output.rb, line 608
def initialize
  super
  @localtime = true

  unless self.class.ancestors.include?(Fluent::Compat::CallSuperMixin)
    self.class.prepend Fluent::Compat::CallSuperMixin
  end
end
propagate_default_params() click to toggle source
# File lib/fluent/compat/output.rb, line 617
def self.propagate_default_params
  BUFFER_PARAMS
end

Private Instance Methods

configure(conf) click to toggle source
Calls superclass method Fluent::Plugin::Output#configure
# File lib/fluent/compat/output.rb, line 622
def configure(conf)
  bufconf = CompatOutputUtils.buffer_section(conf)
  config_style = (bufconf ? :v1 : :v0)
  if config_style == :v0
    buf_params = {
      "flush_mode" => (conf['flush_interval'] ? "interval" : "lazy"),
      "retry_type" => "exponential_backoff",
    }
    BUFFER_PARAMS.each do |older, newer|
      next unless newer
      if conf.has_key?(older)
        if older == 'buffer_queue_full_action' && conf[older] == 'exception'
          buf_params[newer] = 'throw_exception'
        else
          buf_params[newer] = conf[older]
        end
      end
    end

    if conf['timezone']
      Fluent::Timezone.validate!(conf['timezone'])
    elsif conf['utc']
      # v0.12 assumes UTC without any configuration
      # 'localtime=false && no timezone key' means UTC
      conf['localtime'] = "false"
      conf.delete('utc')
    elsif conf['localtime']
      conf['timezone'] = Time.now.strftime('%z')
      conf['localtime'] = "true"
    else
      # v0.12 assumes UTC without any configuration
      # 'localtime=false && no timezone key' means UTC
      conf['localtime'] = "false"
    end

    @_timekey = case conf['time_slice_format']
                when /\%S/ then 1
                when /\%M/ then 60
                when /\%H/ then 3600
                when /\%d/ then 86400
                when nil   then 86400 # default value of TimeSlicedOutput.time_slice_format is '%Y%m%d'
                else
                  raise Fluent::ConfigError, "time_slice_format only with %Y or %m is too long"
                end
    buf_params["timekey"] = @_timekey

    conf.elements << Fluent::Config::Element.new('buffer', 'time', buf_params, [])
  end

  ParserUtils.convert_parser_conf(conf)
  FormatterUtils.convert_formatter_conf(conf)

  super

  if config_style == :v1
    if @buffer_config.chunk_keys == ['tag']
      raise Fluent::ConfigError, "this plugin '#{self.class}' allows <buffer tag> only"
    end
  end

  self.extend TimeSliceChunkMixin
end
detach_multi_process(&block) click to toggle source
# File lib/fluent/compat/output.rb, line 703
def detach_multi_process(&block)
  log.warn "detach_process is not supported in this version. ignored."
  block.call
end
detach_process(&block) click to toggle source
# File lib/fluent/compat/output.rb, line 698
def detach_process(&block)
  log.warn "detach_process is not supported in this version. ignored."
  block.call
end
extract_placeholders(str, metadata) click to toggle source

format MUST be implemented in plugin write is also

# File lib/fluent/compat/output.rb, line 713
def extract_placeholders(str, metadata)
  raise "BUG: compat plugin does not support extract_placeholders: use newer plugin API"
end
start() click to toggle source
Calls superclass method Fluent::Plugin::Output#start
# File lib/fluent/compat/output.rb, line 685
def start
  super

  if instance_variable_defined?(:@formatter) && @inject_config
    unless @formatter.class.ancestors.include?(Fluent::Compat::HandleTagAndTimeMixin)
      if @formatter.respond_to?(:owner) && !@formatter.owner
        @formatter.owner = self
        @formatter.singleton_class.prepend FormatterUtils::InjectMixin
      end
    end
  end
end
support_in_v12_style?(feature) click to toggle source
# File lib/fluent/compat/output.rb, line 557
def support_in_v12_style?(feature)
  case feature
  when :synchronous    then false
  when :buffered       then true
  when :delayed_commit then false
  when :custom_format  then true
  end
end