give logs their own directory
This commit is contained in:
parent
78d5561db3
commit
77d7f8eb81
@ -4,5 +4,6 @@
|
|||||||
"../mods/"
|
"../mods/"
|
||||||
],
|
],
|
||||||
|
|
||||||
"storageDirectory" : "../storage/"
|
"storageDirectory" : "../storage/",
|
||||||
|
"logDirectory" : "../logs/"
|
||||||
}
|
}
|
@ -4,5 +4,6 @@
|
|||||||
"../mods/"
|
"../mods/"
|
||||||
],
|
],
|
||||||
|
|
||||||
"storageDirectory" : "../storage/"
|
"storageDirectory" : "../storage/",
|
||||||
|
"logDirectory" : "../logs/"
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ if exist %client% rmdir %client% /S /Q
|
|||||||
mkdir %client%
|
mkdir %client%
|
||||||
mkdir %client%\storage
|
mkdir %client%\storage
|
||||||
mkdir %client%\mods
|
mkdir %client%\mods
|
||||||
|
mkdir %client%\logs
|
||||||
mkdir %client%\assets
|
mkdir %client%\assets
|
||||||
mkdir %client%\win
|
mkdir %client%\win
|
||||||
|
|
||||||
|
@ -4,5 +4,6 @@
|
|||||||
"..\\mods\\"
|
"..\\mods\\"
|
||||||
],
|
],
|
||||||
|
|
||||||
"storageDirectory" : "..\\storage\\"
|
"storageDirectory" : "..\\storage\\",
|
||||||
|
"logDirectory" : "..\\logs\\"
|
||||||
}
|
}
|
@ -81,12 +81,12 @@ Root::Root(Settings settings) : RootBase() {
|
|||||||
File::makeDirectory(m_settings.storageDirectory);
|
File::makeDirectory(m_settings.storageDirectory);
|
||||||
|
|
||||||
if (m_settings.logFile) {
|
if (m_settings.logFile) {
|
||||||
String logFile = toStoragePath(*m_settings.logFile);
|
String logFile = File::relativeTo(m_settings.logDirectory.value(m_settings.storageDirectory), *m_settings.logFile);
|
||||||
String logDirectory = File::relativeTo(m_settings.storageDirectory, "logs");
|
String oldLogDirectory = m_settings.logDirectory.value(File::relativeTo(m_settings.storageDirectory, "logs"));
|
||||||
if (!File::isDirectory(logDirectory))
|
if (!File::isDirectory(oldLogDirectory))
|
||||||
File::makeDirectory(logDirectory);
|
File::makeDirectory(oldLogDirectory);
|
||||||
|
|
||||||
File::backupFileInSequence(logFile, File::relativeTo(logDirectory, *m_settings.logFile), m_settings.logFileBackups);
|
File::backupFileInSequence(logFile, File::relativeTo(oldLogDirectory, *m_settings.logFile), m_settings.logFileBackups);
|
||||||
Logger::addSink(make_shared<FileLogSink>(logFile, m_settings.logLevel, true));
|
Logger::addSink(make_shared<FileLogSink>(logFile, m_settings.logLevel, true));
|
||||||
}
|
}
|
||||||
Logger::stdoutSink()->setLevel(m_settings.logLevel);
|
Logger::stdoutSink()->setLevel(m_settings.logLevel);
|
||||||
|
@ -71,8 +71,11 @@ public:
|
|||||||
// Top-level storage directory under which all game data is saved
|
// Top-level storage directory under which all game data is saved
|
||||||
String storageDirectory;
|
String storageDirectory;
|
||||||
|
|
||||||
|
// Directory to store logs - if not set, uses storage directory and keeps old logs in seperate folder
|
||||||
|
Maybe<String> logDirectory;
|
||||||
|
|
||||||
// Name of the log file that should be written, if any, relative to the
|
// Name of the log file that should be written, if any, relative to the
|
||||||
// storage directory
|
// log directory
|
||||||
Maybe<String> logFile;
|
Maybe<String> logFile;
|
||||||
|
|
||||||
// Number of rotated log file backups
|
// Number of rotated log file backups
|
||||||
|
@ -173,7 +173,7 @@ Root::Settings RootLoader::rootSettingsForOptions(Options const& options) const
|
|||||||
);
|
);
|
||||||
|
|
||||||
rootSettings.storageDirectory = bootConfig.getString("storageDirectory");
|
rootSettings.storageDirectory = bootConfig.getString("storageDirectory");
|
||||||
|
rootSettings.logDirectory = bootConfig.optString("logDirectory");
|
||||||
rootSettings.logFile = options.parameters.value("logfile").maybeFirst().orMaybe(m_defaults.logFile);
|
rootSettings.logFile = options.parameters.value("logfile").maybeFirst().orMaybe(m_defaults.logFile);
|
||||||
rootSettings.logFileBackups = bootConfig.getUInt("logFileBackups", 10);
|
rootSettings.logFileBackups = bootConfig.getUInt("logFileBackups", 10);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user