add date and time to logged rsync errors

master
itwrx 1 year ago
parent 4ce99e89a4
commit 807c8351c1
  1. 12
      views/routine_list.nim

@ -4,7 +4,7 @@ EZ-Bkup is released under the General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import owlkettle import owlkettle
import osproc, os, logging, sequtils import osproc, os, logging, sequtils, times
import edit_routine_dialog import edit_routine_dialog
import "../models/routine", "../shared" import "../models/routine", "../shared"
@ -27,6 +27,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
createDir(appPath) createDir(appPath)
var logger = newFileLogger(appPath & "/errors.log") 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. :) #i'm not sure if using threadvar here is needed, but doing it just in case. :)
var rsyncRunCmd {.threadvar.}: string var rsyncRunCmd {.threadvar.}: string
@ -57,10 +59,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'" rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'"
rsyncRun = execCmdEx(rsyncRunCmd) rsyncRun = execCmdEx(rsyncRunCmd)
if rsyncRun.exitCode != 0: 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. #handle non-perms related error.
else: 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. #explicitly check that sources were copied to destinations.
#just using file names, mod times, and size (same as bkup run itself). #just using file names, mod times, and size (same as bkup run itself).
#quote sources and destinations to handle possible spaces. #quote sources and destinations to handle possible spaces.
@ -74,10 +76,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
rsyncCheckCmd = "pkexec rsync -rn " & "'" & source & "'" & " " & "'" & destination & "'" rsyncCheckCmd = "pkexec rsync -rn " & "'" & source & "'" & " " & "'" & destination & "'"
rsyncCheckRun = execCmdEx(rsyncCheckCmd) rsyncCheckRun = execCmdEx(rsyncCheckCmd)
if rsyncCheckRun.exitCode != 0: 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. #handle non-perms related error.
else: 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: if rsyncErrors.len > 0:
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Error! Please see ~/.ez-bkup/errors.log</span>" list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Error! Please see ~/.ez-bkup/errors.log</span>"

Loading…
Cancel
Save