[Title] Change query-log format : remove date and send status
authorhataejun <taejun.ha@samsung.com>
Fri, 22 Mar 2013 10:53:10 +0000 (19:53 +0900)
committerhataejun <taejun.ha@samsung.com>
Fri, 22 Mar 2013 10:53:10 +0000 (19:53 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I5023b3fa4e289a7f1c9dba018b1f582d7f33b5f7

src/build_server/BuildServer.rb

index 6645d0eeeea92293b982ca43de83b46aa3997618..56e926f2b3236b59def5654365f1f39ff639574c 100644 (file)
@@ -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
                                                }