Class/Module Index [+]

Quicksearch

Fluent::TimeSlicedOutput

Attributes

localtime[RW]
time_slicer[R]

Public Class Methods

new() click to toggle source
# File lib/fluent/output.rb, line 471
def initialize
  super
  @localtime = true
  #@ignore_old = false   # TODO
end

Public Instance Methods

configure(conf) click to toggle source
# File lib/fluent/output.rb, line 487
def configure(conf)
  super

  if conf['utc']
    @localtime = false
  elsif conf['localtime']
    @localtime = true
  end

  if conf['timezone']
    @timezone = conf['timezone']
    Fluent::Timezone.validate!(@timezone)
  end

  if @timezone
    @time_slicer = Timezone.formatter(@timezone, @time_slice_format)
  elsif @localtime
    @time_slicer = Proc.new {|time|
      Time.at(time).strftime(@time_slice_format)
    }
  else
    @time_slicer = Proc.new {|time|
      Time.at(time).utc.strftime(@time_slice_format)
    }
  end

  @time_slice_cache_interval = time_slice_cache_interval
  @before_tc = nil
  @before_key = nil

  if @flush_interval
    if conf['time_slice_wait']
      $log.warn "time_slice_wait is ignored if flush_interval is specified: #{conf}"
    end
    @enqueue_buffer_proc = Proc.new do
      @buffer.keys.each {|key|
        @buffer.push(key)
      }
    end

  else
    @flush_interval = [60, @time_slice_cache_interval].min
    @enqueue_buffer_proc = Proc.new do
      nowslice = @time_slicer.call(Engine.now.to_i - @time_slice_wait)
      @buffer.keys.each {|key|
        if key < nowslice
          @buffer.push(key)
        end
      }
    end
  end
end
emit(tag, es, chain) click to toggle source
# File lib/fluent/output.rb, line 540
def emit(tag, es, chain)
  @emit_count += 1
  es.each {|time,record|
    tc = time / @time_slice_cache_interval
    if @before_tc == tc
      key = @before_key
    else
      @before_tc = tc
      key = @time_slicer.call(time)
      @before_key = key
    end
    data = format(tag, time, record)
    if @buffer.emit(key, data, chain)
      submit_flush
    end
  }
end
enqueue_buffer(force = false) click to toggle source
# File lib/fluent/output.rb, line 558
def enqueue_buffer(force = false)
  if force
    @buffer.keys.each {|key|
      @buffer.push(key)
    }
  else
    @enqueue_buffer_proc.call
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.