From 51df1874f5b2d31b88ed68a02a910ac091b53af3 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Wed, 14 Dec 2022 16:33:50 +0100 Subject: [PATCH] agent: some better logging --- src/agent/daemon.v | 10 ++++------ src/build/build.v | 5 +++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/agent/daemon.v b/src/agent/daemon.v index ff29d5e4..0647733f 100644 --- a/src/agent/daemon.v +++ b/src/agent/daemon.v @@ -146,7 +146,7 @@ fn (mut d AgentDaemon) start_build(config BuildConfig) bool { // run_build actually starts the build process for a given target. fn (mut d AgentDaemon) run_build(build_index int, config BuildConfig) { - d.linfo('started build: $config.url -> $config.repo') + d.linfo('started build: $config') // 0 means success, 1 means failure mut status := 0 @@ -164,16 +164,14 @@ fn (mut d AgentDaemon) run_build(build_index int, config BuildConfig) { } if status == 0 { - d.linfo('finished build: $config.url -> $config.repo; uploading logs...') + d.linfo('Uploading build logs for $config') // TODO use the arch value here build_arch := os.uname().machine d.client.add_build_log(config.target_id, res.start_time, res.end_time, build_arch, - res.exit_code, res.logs) or { - d.lerror('Failed to upload logs for build: $config.url -> $config.repo') - } + res.exit_code, res.logs) or { d.lerror('Failed to upload logs for $config') } } else { - d.linfo('an error occured during build: $config.url -> $config.repo') + d.lwarn('an error occurred during build: $config') } stdatomic.store_u64(&d.atomics[build_index], agent.build_done) diff --git a/src/build/build.v b/src/build/build.v index 6da851a2..3d916bf2 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -27,6 +27,11 @@ pub: force bool } +// str return a single-line string representation of a build log +pub fn (c BuildConfig) str() string { + return '{ target: $c.target_id, kind: $c.kind, url: $c.url, branch: $c.branch, repo: $c.repo, base_image: $c.base_image, force: $c.force }' +} + // create_build_image creates a builder image given some base image which can // then be used to build & package Arch images. It mostly just updates the // system, install some necessary packages & creates a non-root user to run