Sha256: 055e684e4cf94658e6f289fe6be8f9cc66e5628fbd1455b4598243c1dfa92940

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

module Pione
  module Command
    # PioneLog is a command for viewing PIONE log or converting into other formats.
    class PioneLog < BasicCommand
      define_info do
        set_name "pione-log"
        set_banner "View and convert PIONE log."
      end

      define_option do
        default :format, :xes
        default :trace_filter, []
        default :output, Location["local:./output"]

        option("--agent-activity[=TYPE]", "output only agent activity log") do |data, name|
          data[:trace_filter] << Proc.new do |trace|
            trace.attributes.include?(XES.string("pione:traceType", "agent_activity")) and
              (name.nil? or trace.events.first.org_resource == name)
          end
        end

        option("--rule-process", "generate rule process log") do |data|
          data[:trace_filter] << Proc.new do |trace|
            trace.attributes.include?(XES.string("pione:traceType", "rule_process"))
          end
        end

        option("--task-process", "generate task process log") do |data|
          data[:trace_filter] << Proc.new do |trace|
            trace.attributes.include?(XES.string("pione:traceType", "task_process"))
          end
        end

        option("--location=LOCATION", "set log location of PIONE process") do |data, location|
          data[:output] = Location[location]
        end

        option("--format=(XES|JSON|HTML)", "set format type") do |data, name|
          data[:format] = name.downcase.to_sym
        end

        validate do |data|
          unless data[:output].exist?
            abort("File or directory not found in the location: %s" % data[:output].uri.to_s)
          end
        end
      end

      start do
        Log::ProcessLog[option[:format]].tap do |formatter|
          if formatter
            $stdout.puts(formatter.read(option[:output]).format(option[:trace_filter]))
            $stdout.flush
          else
            abort("Unknown format: %s" % option[:format])
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pione-0.1.4 lib/pione/command/pione-log.rb
pione-0.1.3 lib/pione/command/pione-log.rb