From e3f011b724105d4a4c76d858317bce0c5657b2b7 Mon Sep 17 00:00:00 2001 From: skilion Date: Thu, 28 Dec 2017 15:21:41 +0100 Subject: [PATCH] write logs on stdout instead of stderr --- src/log.d | 9 +++++++-- src/main.d | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/log.d b/src/log.d index 70d805ca..82a567b9 100644 --- a/src/log.d +++ b/src/log.d @@ -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); +} \ No newline at end of file diff --git a/src/main.d b/src/main.d index eed7d551..dace3db5 100644 --- a/src/main.d +++ b/src/main.d @@ -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;