diff --git a/README.md b/README.md index 699b74c2..e3185dd3 100644 --- a/README.md +++ b/README.md @@ -499,7 +499,7 @@ no option No sync and exit --syncdir Set the directory used to sync the files that are synced --synchronize Perform a synchronization --upload-only Only upload to OneDrive, do not sync changes from OneDrive locally --v --verbose Print more details, useful for debugging +-v --verbose Print more details, useful for debugging (repeat for extra debugging) --version Print the version and exit -h --help This help information. ``` diff --git a/onedrive.1.in b/onedrive.1.in index 67a6ada7..fd6201a3 100644 --- a/onedrive.1.in +++ b/onedrive.1.in @@ -79,7 +79,8 @@ Perform a synchronization Only upload to OneDrive, do not sync changes from OneDrive locally .TP \fB\-v \-\-verbose\fP -Print more details, useful for debugging +Print more details, useful for debugging. Given two times (or more) +enables even more verbose debug statements. .TP \fB\-\-version\fP Print the version and exit diff --git a/src/log.d b/src/log.d index cc2c8cf9..db0d63b9 100644 --- a/src/log.d +++ b/src/log.d @@ -10,7 +10,7 @@ version(Notifications) { } // enable verbose logging -bool verbose; +int verbose; bool writeLogFile = false; private bool doNotifications; @@ -69,7 +69,7 @@ void fileOnly(T...)(T args) void vlog(T...)(T args) { - if (verbose) { + if (verbose >= 1) { writeln(args); if(writeLogFile){ // Write to log file @@ -78,6 +78,17 @@ void vlog(T...)(T args) } } +void vdebug(T...)(T args) +{ + if (verbose >= 2) { + writeln("[DEBUG] ", args); + if(writeLogFile){ + // Write to log file + logfileWriteLine("[DEBUG] ", args); + } + } +} + void error(T...)(T args) { stderr.writeln(args); diff --git a/src/main.d b/src/main.d index df86b95e..0779ded7 100644 --- a/src/main.d +++ b/src/main.d @@ -121,7 +121,7 @@ int main(string[] args) "syncdir", "Set the directory used to sync the files that are synced", &syncDirName, "synchronize", "Perform a synchronization", &synchronize, "upload-only", "Only upload to OneDrive, do not sync changes from OneDrive locally", &uploadOnly, - "verbose|v", "Print more details, useful for debugging", &log.verbose, + "verbose|v+", "Print more details, useful for debugging (repeat for extra debugging)", &log.verbose, "version", "Print the version and exit", &printVersion ); if (opt.helpWanted) { diff --git a/src/monitor.d b/src/monitor.d index 17cc9db8..135ceec7 100644 --- a/src/monitor.d +++ b/src/monitor.d @@ -186,8 +186,10 @@ final class Monitor } if (event.mask & IN_MOVED_FROM) { + log.vdebug("event IN_MOVED_FROM: ", path); cookieToPath[event.cookie] = path; } else if (event.mask & IN_MOVED_TO) { + log.vdebug("event IN_MOVED_TO: ", path); if (event.mask & IN_ISDIR) addRecursive(path); auto from = event.cookie in cookieToPath; if (from) { @@ -202,15 +204,19 @@ final class Monitor } } } else if (event.mask & IN_CREATE) { + log.vdebug("event IN_CREATE: ", path); if (event.mask & IN_ISDIR) { addRecursive(path); if (useCallbacks) onDirCreated(path); } } else if (event.mask & IN_DELETE) { + log.vdebug("event IN_DELETE: ", path); if (useCallbacks) onDelete(path); } else if ((event.mask & IN_CLOSE_WRITE) && !(event.mask & IN_ISDIR)) { + log.vdebug("event IN_CLOSE_WRITE and ...: ", path); if (useCallbacks) onFileChanged(path); } else { + log.vdebug("event unhandled: ", path); assert(0); } @@ -219,6 +225,7 @@ final class Monitor } // assume that the items moved outside the watched directory have been deleted foreach (cookie, path; cookieToPath) { + log.vdebug("deleting (post loop): ", path); if (useCallbacks) onDelete(path); remove(path); cookieToPath.remove(cookie);