write logs on stdout instead of stderr

This commit is contained in:
skilion 2017-12-28 15:21:41 +01:00
parent 35ce743b39
commit e3f011b724
2 changed files with 11 additions and 6 deletions

View file

@ -5,10 +5,15 @@ bool verbose;
void log(T...)(T args)
{
stderr.writeln(args);
writeln(args);
}
void vlog(T...)(T args)
{
if (verbose) stderr.writeln(args);
if (verbose) writeln(args);
}
void error(T...)(T args)
{
stderr.writeln(args);
}

View file

@ -46,8 +46,8 @@ int main(string[] args)
return EXIT_SUCCESS;
}
} catch (GetOptException e) {
log.log(e.msg);
log.log("Try 'onedrive -h' for more information");
log.error(e.msg);
log.error("Try 'onedrive -h' for more information");
return EXIT_FAILURE;
}
@ -85,13 +85,13 @@ int main(string[] args)
log.vlog("Initializing the OneDrive API ...");
bool online = testNetwork();
if (!online && !monitor) {
log.log("No network connection");
log.error("No network connection");
return EXIT_FAILURE;
}
auto onedrive = new OneDriveApi(cfg);
onedrive.printAccessToken = printAccessToken;
if (!onedrive.init()) {
log.log("Could not initialize the OneDrive API");
log.error("Could not initialize the OneDrive API");
// workaround for segfault in std.net.curl.Curl.shutdown() on exit
onedrive.http.shutdown();
return EXIT_FAILURE;