abraunegg-onedrive/src/log.d
abraunegg dd73ae3c4b OneDrive Client Changes
* Fix 4xx errors including (412 pre-condition)
* Add Logging - log to a file (/var/log/onedrive/onedrive.log)
* Add http(s) debugging as a flag
* Add dont sync when just blindly running the application
* Add individual folder sync - ie ~/OneDrive/blah/ vs. syncing
everything in ~/OneDrive/
* Add sync from local directory first rather than download first then
upload
* Add upload long path check (430 character limitation)
2018-03-14 15:43:40 +11:00

44 lines
1 KiB
D

import std.stdio;
import std.file;
import std.datetime;
// enable verbose logging
bool verbose;
void log(T...)(T args)
{
writeln(args);
// Write to log file
string logFileName = "/var/log/onedrive/onedrive.log";
auto currentTime = Clock.currTime();
auto timeString = currentTime.toString();
File logFile = File(logFileName, "a");
logFile.writeln(timeString, " ", args);
logFile.close();
}
void vlog(T...)(T args)
{
if (verbose) {
writeln(args);
// Write to log file
string logFileName = "/var/log/onedrive/onedrive.log";
auto currentTime = Clock.currTime();
auto timeString = currentTime.toString();
File logFile = File(logFileName, "a");
logFile.writeln(timeString, " ", args);
logFile.close();
}
}
void error(T...)(T args)
{
stderr.writeln(args);
// Write to log file
string logFileName = "/var/log/onedrive/onedrive.log";
auto currentTime = Clock.currTime();
auto timeString = currentTime.toString();
File logFile = File(logFileName, "a");
logFile.writeln(timeString, " ", args);
logFile.close();
}