class Fluent::TextParser::UiPathParser

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_uipath.rb, line 11
def initialize
  super
  require 'json'
end

Public Instance Methods

parse(text) { |time, record| ... } click to toggle source
# File lib/fluent/plugin/parser_uipath.rb, line 16
def parse(text)
  time = Fluent::Engine.now
  record = { 'raw' => text }
  
  text = text.encode('UTF-16BE', @encoding,
                     :invalid => :replace, :undef => :replace,
                     :replace => '?').encode('UTF-8')
  
  if md = text.match(/^[^ ]* [^ ]* (.*)$/)
    record = JSON.parse(md[1])
    if record.has_key?('timeStamp')
      time = Time.parse(record['timeStamp']).to_i
      record['timeStamp'] = time.to_json
    end
  end
  
  yield time, record
  return
end