[pbs-devel] [PATCH proxmox-backup 1/8] worker_task: refactor log text generator
Dominik Csapak
d.csapak at proxmox.com
Fri Jul 31 14:43:23 CEST 2020
we will need this elsewhere, so pull it out
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/server/worker_task.rs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs
index af6686fd..f6882d13 100644
--- a/src/server/worker_task.rs
+++ b/src/server/worker_task.rs
@@ -502,17 +502,23 @@ impl WorkerTask {
Ok(upid_str)
}
- /// Log task result, remove task from running list
- pub fn log_result(&self, result: &Result<(), Error>) {
+ /// get the Text of the result
+ pub fn get_log_text(&self, result: &Result<(), Error>) -> String {
let warn_count = self.data.lock().unwrap().warn_count;
+
if let Err(err) = result {
- self.log(&format!("TASK ERROR: {}", err));
+ format!("ERROR: {}", err)
} else if warn_count > 0 {
- self.log(format!("TASK WARNINGS: {}", warn_count));
+ format!("WARNINGS: {}", warn_count)
} else {
- self.log("TASK OK");
+ "OK".to_string()
}
+ }
+
+ /// Log task result, remove task from running list
+ pub fn log_result(&self, result: &Result<(), Error>) {
+ self.log(format!("TASK {}", self.get_log_text(result)));
WORKER_TASK_LIST.lock().unwrap().remove(&self.upid.task_id);
let _ = update_active_workers(None);
--
2.20.1
More information about the pbs-devel
mailing list