From 807c8351c186197cfbde82cd9d3e8ed50aedb012 Mon Sep 17 00:00:00 2001 From: itwrx Date: Sun, 6 Aug 2023 10:15:29 -0500 Subject: [PATCH] add date and time to logged rsync errors --- views/routine_list.nim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/views/routine_list.nim b/views/routine_list.nim index 04c5507..6108f0c 100644 --- a/views/routine_list.nim +++ b/views/routine_list.nim @@ -4,7 +4,7 @@ EZ-Bkup is released under the General Public License 3.0. See COPYING or for details.]# import owlkettle -import osproc, os, logging, sequtils +import osproc, os, logging, sequtils, times import edit_routine_dialog import "../models/routine", "../shared" @@ -27,6 +27,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} = createDir(appPath) var logger = newFileLogger(appPath & "/errors.log") + let dt = now() + let nowDT = dt.format("M-d-YYYY h:mm:ss tt") #i'm not sure if using threadvar here is needed, but doing it just in case. :) var rsyncRunCmd {.threadvar.}: string @@ -57,10 +59,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} = rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'" rsyncRun = execCmdEx(rsyncRunCmd) if rsyncRun.exitCode != 0: - rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination) + rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination) #handle non-perms related error. else: - rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination) + rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination) #explicitly check that sources were copied to destinations. #just using file names, mod times, and size (same as bkup run itself). #quote sources and destinations to handle possible spaces. @@ -74,10 +76,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} = rsyncCheckCmd = "pkexec rsync -rn " & "'" & source & "'" & " " & "'" & destination & "'" rsyncCheckRun = execCmdEx(rsyncCheckCmd) if rsyncCheckRun.exitCode != 0: - rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination) + rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination) #handle non-perms related error. else: - rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination) + rsyncErrors.add("(" & nowDT & ")" & "EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination) if rsyncErrors.len > 0: list.runStatus = "Error! Please see ~/.ez-bkup/errors.log"