From: hataejun Date: Fri, 22 Mar 2013 10:53:10 +0000 (+0900) Subject: [Title] Change query-log format : remove date and send status X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23db6def696fd3f8337c5ab099cfd7e56c3147cb;p=sdk%2Ftools%2Fsdk-build.git [Title] Change query-log format : remove date and send status [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] Change-Id: I5023b3fa4e289a7f1c9dba018b1f582d7f33b5f7 --- diff --git a/src/build_server/BuildServer.rb b/src/build_server/BuildServer.rb index 6645d0e..56e926f 100644 --- a/src/build_server/BuildServer.rb +++ b/src/build_server/BuildServer.rb @@ -797,15 +797,36 @@ class BuildServer job_log_path = File.join(@path, "jobs", job_number, "log") if File.exist? job_log_path then + # get job status and send it + job_status = "" + if job.nil? then + get_db_connection() do |db| + job_status = db.select_one("SELECT status FROM jobs WHERE id = #{job_number}")[0] + end + else + job_status = job.status + end + BuildCommServer.send(conn, "JOB STATUS : [[#{job_status}]]") + begin File::Tail::Logfile.open(job_log_path) do |log| + # skip log file creation information + log.forward(1) + + # send log file information using file-tail log.tail { |line| - BuildCommServer.send(conn, line) + if line.strip.empty? then next end + contents = line.sub(/^[a-zA-Z], \[.*\][ \t]*/,"") + BuildCommServer.send(conn, contents) - if log.eof? and (job.nil? or - job.status.eql? "FINISHED" or - job.status.eql? "ERROR" or - job.status.eql? "CANCELED") then + # if read file's last line and job status ended then log file sending done + if not job.nil? then job_status = job.status end + if log.eof? and + (job_status.eql? "FINISHED" or + job_status.eql? "ERROR" or + job_status.eql? "CANCELED") then + # Log file send done. & send job status + BuildCommServer.send(conn, "JOB STATUS : [[#{job_status}]]") break end }