Commit 5b23c34c authored by Iustin Pop's avatar Iustin Pop
Browse files

Add opcode execution log in job info

This patch adds the job execution log in “gnt-job info” and also allows
its selection in “gnt-job list” (however here it's not very useful as
it's not easy to parse). It does this by adding a new field in the query
job call, named ‘oplog’.

With this, one can get a very clear examination of the job. What remains
to be added would be timestamps for start/stop of the processing for the
job itself and its opcodes.

Reviewed-by: imsnah
parent 3c03759a
......@@ -696,6 +696,8 @@ class JobQueue(object):
row.append([op.result for op in job.ops])
elif fname == "opstatus":
row.append([op.status for op in job.ops])
elif fname == "oplog":
row.append([op.log for op in job.ops])
elif fname == "summary":
row.append([op.input.Summary() for op in job.ops])
......@@ -22,6 +22,7 @@
import sys
import os
import itertools
import time
from optparse import make_option
from cStringIO import StringIO
......@@ -64,6 +65,7 @@ def ListJobs(opts, args):
"ops": "OpCodes",
"opresult": "OpCode_result",
"opstatus": "OpCode_status",
"oplog": "OpCode_log",
"summary": "Summary",
......@@ -129,13 +131,13 @@ def ShowJobs(opts, args):
return str(value)
selected_fields = ["id", "status", "ops", "opresult", "opstatus"]
selected_fields = ["id", "status", "ops", "opresult", "opstatus", "oplog"]
result = GetClient().QueryJobs(args, selected_fields)
first = True
for job_id, status, ops, opresult, opstatus in result:
for job_id, status, ops, opresult, opstatus, oplog in result:
if not first:
format(0, "")
......@@ -148,7 +150,7 @@ def ShowJobs(opts, args):
format(1, "Status: %s" % status)
format(1, "Opcodes:")
for opcode, result, status in zip(ops, opresult, opstatus):
for opcode, result, status, log in zip(ops, opresult, opstatus, oplog):
format(2, "%s" % opcode["OP_ID"])
format(3, "Status: %s" % status)
format(3, "Input fields:")
......@@ -175,6 +177,11 @@ def ShowJobs(opts, args):
format(4, "%s: %s" % (key, result_helper(val)))
format(3, "Result: %s" % result)
format(3, "Execution log:")
for serial, (sec, usec), log_type, log_msg in log:
time_txt = time.strftime("%F %T", time.localtime(sec)) + ".%06d" % usec
encoded = str(log_msg).encode('string_escape')
format(4, "%s:%s:%s %s" % (serial, time_txt, log_type, encoded))
return 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment