From d4b733ae89deb641869f0face86ffd1f74c429ae Mon Sep 17 00:00:00 2001 From: abraunegg Date: Wed, 4 May 2022 06:03:45 +1000 Subject: [PATCH] Update when sync start and complete is written to application log file if enabled (#1947) * When using the application with 'defaults' with logging enabled and no verbose mode, the application output that a sync process has started & finished is only written to the logfile every 5 sync times (25 mins). This change updates this so that, if defaults are being used with logging enabled and no verbose mode, the application will always, at a minimum, write out to the application log file when a sync was started and when it was completed. This provides important reference in the log as to when an activity began and was completed. --- src/main.d | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.d b/src/main.d index db3f00d6..0d23c53b 100644 --- a/src/main.d +++ b/src/main.d @@ -1303,8 +1303,16 @@ int main(string[] args) return EXIT_FAILURE; } try { + string startMessage = "Starting a sync with OneDrive"; + string finishMessage = "Sync with OneDrive is complete"; // perform a --monitor sync - if ((cfg.getValueLong("verbose") > 0) || (logMonitorCounter == logInterval)) log.log("Starting a sync with OneDrive"); + if ((cfg.getValueLong("verbose") > 0) || (logMonitorCounter == logInterval)) { + // log to console and log file if enabled + log.log(startMessage); + } else { + // log file only if enabled so we know when a sync started when not using --verbose + log.fileOnly(startMessage); + } performSync(sync, cfg.getValueString("single_directory"), cfg.getValueBool("download_only"), cfg.getValueBool("local_first"), cfg.getValueBool("upload_only"), (logMonitorCounter == logInterval ? MONITOR_LOG_QUIET : MONITOR_LOG_SILENT), fullScanRequired, syncListConfiguredFullScanOverride, displaySyncOptions, cfg.getValueBool("monitor"), m); if (!cfg.getValueBool("download_only")) { // discard all events that may have been generated by the sync that have not already been handled @@ -1315,7 +1323,13 @@ int main(string[] args) log.error("ERROR: The following inotify error was generated: ", e.msg); } } - if ((cfg.getValueLong("verbose") > 0) || (logMonitorCounter == logInterval)) log.log("Sync with OneDrive is complete"); + if ((cfg.getValueLong("verbose") > 0) || (logMonitorCounter == logInterval)) { + // log to console and log file if enabled + log.log(finishMessage); + } else { + // log file only if enabled so we know when a sync completed when not using --verbose + log.fileOnly(finishMessage); + } } catch (CurlException e) { // we already tried three times in the performSync routine // if we still have problems, then the sync handle might have