Signed-off-by: Wu Zhende wuzhende666@163.com --- src/lib/sched.cr | 3 +-- src/scheduler/find_job_boot.cr | 6 +++--- src/scheduler/submit_job.cr | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 22e0e4e..abb8a33 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -34,8 +34,7 @@ class Sched @block_helper = BlockHelper.new @rgc = RemoteGitClient.new @env = env - @log = JSONLogger.new - @log.set_env(env) + @log = env.get("log").as(JSONLogger) end
def normalize_mac(mac : String) diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index 6f51640..3e33604 100644 --- a/src/scheduler/find_job_boot.cr +++ b/src/scheduler/find_job_boot.cr @@ -192,15 +192,15 @@ class Sched begin job = @es.get_job(job_id.to_s) rescue ex - puts "Invalid job (id=#{job_id}) in es. Info: #{ex}" - puts ex.inspect_with_backtrace + @log.warn("Invalid job (id=#{job_id}) in es. Info: #{ex}") + @log.warn(ex.inspect_with_backtrace) end end
if job job.update({"testbox" => testbox}) job.set_result_root - puts %({"job_id": "#{job_id}", "result_root": "/srv#{job.result_root}", "job_state": "set result root"}) + @log.info(%({"job_id": "#{job_id}", "result_root": "/srv#{job.result_root}", "job_state": "set result root"})) @redis.set_job(job) end return job diff --git a/src/scheduler/submit_job.cr b/src/scheduler/submit_job.cr index a9eb3a7..f93ad2b 100644 --- a/src/scheduler/submit_job.cr +++ b/src/scheduler/submit_job.cr @@ -19,7 +19,7 @@ class Sched return submit_cluster_job(job, cluster_config) end rescue ex - puts ex.inspect_with_backtrace + @log.warn(ex.inspect_with_backtrace) return [{ "job_id" => "0", "message" => ex.to_s,