mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-16 12:45:14 +02:00
Add very verbose (debug) mode by double -v -v (#279)
* Add very verbose (debug) mode by double -v -v - currently only used for debugging the inotify events
This commit is contained in:
parent
87cd18379d
commit
3608dcc4c2
|
@ -499,7 +499,7 @@ no option No sync and exit
|
||||||
--syncdir Set the directory used to sync the files that are synced
|
--syncdir Set the directory used to sync the files that are synced
|
||||||
--synchronize Perform a synchronization
|
--synchronize Perform a synchronization
|
||||||
--upload-only Only upload to OneDrive, do not sync changes from OneDrive locally
|
--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
|
--version Print the version and exit
|
||||||
-h --help This help information.
|
-h --help This help information.
|
||||||
```
|
```
|
||||||
|
|
|
@ -79,7 +79,8 @@ Perform a synchronization
|
||||||
Only upload to OneDrive, do not sync changes from OneDrive locally
|
Only upload to OneDrive, do not sync changes from OneDrive locally
|
||||||
.TP
|
.TP
|
||||||
\fB\-v \-\-verbose\fP
|
\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
|
.TP
|
||||||
\fB\-\-version\fP
|
\fB\-\-version\fP
|
||||||
Print the version and exit
|
Print the version and exit
|
||||||
|
|
15
src/log.d
15
src/log.d
|
@ -10,7 +10,7 @@ version(Notifications) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable verbose logging
|
// enable verbose logging
|
||||||
bool verbose;
|
int verbose;
|
||||||
bool writeLogFile = false;
|
bool writeLogFile = false;
|
||||||
|
|
||||||
private bool doNotifications;
|
private bool doNotifications;
|
||||||
|
@ -69,7 +69,7 @@ void fileOnly(T...)(T args)
|
||||||
|
|
||||||
void vlog(T...)(T args)
|
void vlog(T...)(T args)
|
||||||
{
|
{
|
||||||
if (verbose) {
|
if (verbose >= 1) {
|
||||||
writeln(args);
|
writeln(args);
|
||||||
if(writeLogFile){
|
if(writeLogFile){
|
||||||
// Write to log file
|
// 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)
|
void error(T...)(T args)
|
||||||
{
|
{
|
||||||
stderr.writeln(args);
|
stderr.writeln(args);
|
||||||
|
|
|
@ -121,7 +121,7 @@ int main(string[] args)
|
||||||
"syncdir", "Set the directory used to sync the files that are synced", &syncDirName,
|
"syncdir", "Set the directory used to sync the files that are synced", &syncDirName,
|
||||||
"synchronize", "Perform a synchronization", &synchronize,
|
"synchronize", "Perform a synchronization", &synchronize,
|
||||||
"upload-only", "Only upload to OneDrive, do not sync changes from OneDrive locally", &uploadOnly,
|
"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
|
"version", "Print the version and exit", &printVersion
|
||||||
);
|
);
|
||||||
if (opt.helpWanted) {
|
if (opt.helpWanted) {
|
||||||
|
|
|
@ -186,8 +186,10 @@ final class Monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.mask & IN_MOVED_FROM) {
|
if (event.mask & IN_MOVED_FROM) {
|
||||||
|
log.vdebug("event IN_MOVED_FROM: ", path);
|
||||||
cookieToPath[event.cookie] = path;
|
cookieToPath[event.cookie] = path;
|
||||||
} else if (event.mask & IN_MOVED_TO) {
|
} else if (event.mask & IN_MOVED_TO) {
|
||||||
|
log.vdebug("event IN_MOVED_TO: ", path);
|
||||||
if (event.mask & IN_ISDIR) addRecursive(path);
|
if (event.mask & IN_ISDIR) addRecursive(path);
|
||||||
auto from = event.cookie in cookieToPath;
|
auto from = event.cookie in cookieToPath;
|
||||||
if (from) {
|
if (from) {
|
||||||
|
@ -202,15 +204,19 @@ final class Monitor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.mask & IN_CREATE) {
|
} else if (event.mask & IN_CREATE) {
|
||||||
|
log.vdebug("event IN_CREATE: ", path);
|
||||||
if (event.mask & IN_ISDIR) {
|
if (event.mask & IN_ISDIR) {
|
||||||
addRecursive(path);
|
addRecursive(path);
|
||||||
if (useCallbacks) onDirCreated(path);
|
if (useCallbacks) onDirCreated(path);
|
||||||
}
|
}
|
||||||
} else if (event.mask & IN_DELETE) {
|
} else if (event.mask & IN_DELETE) {
|
||||||
|
log.vdebug("event IN_DELETE: ", path);
|
||||||
if (useCallbacks) onDelete(path);
|
if (useCallbacks) onDelete(path);
|
||||||
} else if ((event.mask & IN_CLOSE_WRITE) && !(event.mask & IN_ISDIR)) {
|
} else if ((event.mask & IN_CLOSE_WRITE) && !(event.mask & IN_ISDIR)) {
|
||||||
|
log.vdebug("event IN_CLOSE_WRITE and ...: ", path);
|
||||||
if (useCallbacks) onFileChanged(path);
|
if (useCallbacks) onFileChanged(path);
|
||||||
} else {
|
} else {
|
||||||
|
log.vdebug("event unhandled: ", path);
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +225,7 @@ final class Monitor
|
||||||
}
|
}
|
||||||
// assume that the items moved outside the watched directory have been deleted
|
// assume that the items moved outside the watched directory have been deleted
|
||||||
foreach (cookie, path; cookieToPath) {
|
foreach (cookie, path; cookieToPath) {
|
||||||
|
log.vdebug("deleting (post loop): ", path);
|
||||||
if (useCallbacks) onDelete(path);
|
if (useCallbacks) onDelete(path);
|
||||||
remove(path);
|
remove(path);
|
||||||
cookieToPath.remove(cookie);
|
cookieToPath.remove(cookie);
|
||||||
|
|
Loading…
Reference in a new issue