|
@@ -20,8 +20,6 @@ import configuration;
|
|
|
import std.experimental.logger;
|
|
|
import pd_version : PIXIV_DOWN_VERSION;
|
|
|
|
|
|
-enum kPixivDownLogFileName = "pixiv_down.log";
|
|
|
-
|
|
|
version(PD_USE_GAMUT)
|
|
|
{
|
|
|
pragma(msg, "NOTE: pixiv_down doesn't make proper use of gamut yet. GIFs won't download successfully.");
|
|
@@ -158,70 +156,6 @@ void logLibGMVersion()
|
|
|
|
|
|
} // version(PD_USE_MAGICK)
|
|
|
|
|
|
-void setupLoggerFromEnvironment()
|
|
|
-{
|
|
|
- import std.process : environment;
|
|
|
- import std.stdio : stderr;
|
|
|
- import std.uni : toLower;
|
|
|
- import logger;
|
|
|
-
|
|
|
- LogLevel level = LogLevel.warning;
|
|
|
- if ("PIXIV_DOWN_LOG_LEVEL" in environment) {
|
|
|
- const value = environment["PIXIV_DOWN_LOG_LEVEL"].toLower;
|
|
|
- switch(value) {
|
|
|
- case "all":
|
|
|
- level = LogLevel.all;
|
|
|
- break;
|
|
|
- case "trace":
|
|
|
- level = LogLevel.trace;
|
|
|
- break;
|
|
|
- case "info":
|
|
|
- level = LogLevel.info;
|
|
|
- break;
|
|
|
- case "debug":
|
|
|
- stderr.writeln("NOTE: The 'debug' log level is no longer supported.");
|
|
|
- stderr.writeln(" Falling back to 'warning'.");
|
|
|
- level = LogLevel.warning;
|
|
|
- break;
|
|
|
- case "warning":
|
|
|
- level = LogLevel.warning;
|
|
|
- break;
|
|
|
- case "error":
|
|
|
- level = LogLevel.error;
|
|
|
- break;
|
|
|
- case "fatal":
|
|
|
- level = LogLevel.fatal;
|
|
|
- break;
|
|
|
- default:
|
|
|
- stderr.writeln("Unknown log level: ", level);
|
|
|
- stderr.writeln("Supported values are: trace, info, warning, error, and fatal.");
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- static if (__VERSION__ < 2101L) {
|
|
|
- sharedLog = new PDLogger(kPixivDownLogFileName, level);
|
|
|
- } else {
|
|
|
- sharedLog = cast(shared(PDLogger))new PDLogger(kPixivDownLogFileName, level);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void logCompilationInfo()
|
|
|
-{
|
|
|
- const bits = (void*).sizeof == 8 ? "64" : "32";
|
|
|
- version (linux)
|
|
|
- const system = "Linux";
|
|
|
- else version (Windows)
|
|
|
- const system = "Windows";
|
|
|
- else version (OSX)
|
|
|
- const system = "macOS";
|
|
|
- else
|
|
|
- const system = "Unknown";
|
|
|
-
|
|
|
- infof("pixiv_down %s started", PIXIV_DOWN_VERSION);
|
|
|
- infof("Running on %s | %s-bit build | %s %,?d", system, bits, __VENDOR__, '.', __VERSION__);
|
|
|
-}
|
|
|
-
|
|
|
/// Returns the two character locale set in the environment.
|
|
|
string getLocale()
|
|
|
{
|
|
@@ -257,6 +191,7 @@ int main(string[] args)
|
|
|
import pixiv : fetchCSRFToken;
|
|
|
import std.stdio : stderr, writeln, writefln;
|
|
|
import std.file : exists, remove;
|
|
|
+ import logger: initializeLogger;
|
|
|
|
|
|
auto subcmds = [
|
|
|
"artist": &artistHandle,
|
|
@@ -345,12 +280,7 @@ int main(string[] args)
|
|
|
return 2;
|
|
|
}
|
|
|
|
|
|
- if (exists(kPixivDownLogFileName)) {
|
|
|
- remove(kPixivDownLogFileName);
|
|
|
- }
|
|
|
-
|
|
|
- setupLoggerFromEnvironment();
|
|
|
- logCompilationInfo();
|
|
|
+ initializeLogger();
|
|
|
|
|
|
version(PD_USE_MAGICK)
|
|
|
{
|