diff --git a/CMakeLists.txt b/CMakeLists.txt index 84d7360..9eba300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ set(APP_AUTHOR "bakatrouble") set(VERSION_MAJOR 0) set(VERSION_MINOR 0) -set(VERSION_MICRO 8) +set(VERSION_MICRO 10) set(APP_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}") diff --git a/config.ini b/config.ini index 23b2400..a36a4c1 100644 --- a/config.ini +++ b/config.ini @@ -5,6 +5,8 @@ default_destination = default upload_screenshots = true upload_movies = true +; keep_logs = true + ; url = https://screenuploader.bakatrouble.me/upload// ; do not change previous line unless you setup your own server! diff --git a/src/config.cpp b/src/config.cpp index 7082952..554f78c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -24,6 +24,7 @@ bool Config::refresh() { m_defaultDestID = reader.Get("server", "destination_id", "undefined"); m_uploadScreenshots = reader.GetBoolean("server", "upload_screenshots", true); m_uploadMovies = reader.GetBoolean("server", "upload_movies", true); + m_keepLogs = reader.GetBoolean("server", "keep_logs", false); if (reader.Sections().count("destinations") > 0) { map destinations; @@ -101,3 +102,7 @@ bool Config::uploadAllowed(string &tid, bool isMovie) { return m_uploadScreenshots; } } + +bool Config::keepLogs() { + return m_keepLogs; +} diff --git a/src/config.hpp b/src/config.hpp index 43296e3..72cd643 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -17,12 +17,14 @@ class Config { string getUrl(string &tid); string getUrlParams(); bool uploadAllowed(string &tid, bool isMovie); + bool keepLogs(); protected: string m_url = "https://screenuploader.bakatrouble.me/upload/" + URLplaceholder + "/"; string m_defaultDestID; bool m_uploadScreenshots; bool m_uploadMovies; + bool m_keepLogs; map m_titleSettings; map m_titleScreenshots; map m_titleMovies; diff --git a/src/main.cpp b/src/main.cpp index bf7318a..e51bbdb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -105,17 +105,28 @@ extern "C" { } } +static ofstream log; + +void openLogFile(bool truncate) { + log = ofstream ("sdmc:/config/sys-screenuploader/screenuploader.log", truncate ? ios::trunc : ios::app); + cout.rdbuf(log.rdbuf()); + cerr.rdbuf(log.rdbuf()); + cout << "=============================" << endl << endl << endl; + cout << "ScreenUploader v" << APP_VERSION << " is starting..." << endl; +} + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" int main(int argc, char **argv) { mkdir("sdmc:/config", 0700); mkdir("sdmc:/config/sys-screenuploader", 0700); - ofstream log("sdmc:/config/sys-screenuploader/screenuploader.log", ios::app); - cout.rdbuf(log.rdbuf()); - cerr.rdbuf(log.rdbuf()); - cout << "=============================" << endl << endl << endl; - cout << "ScreenUploader v" << APP_VERSION << " is starting..." << endl; + openLogFile(false); + Config conf = Config::load(); + if (!conf.keepLogs()) { + log.close(); + openLogFile(true); + } Result rc; CapsAlbumStorage storage; @@ -137,7 +148,6 @@ int main(int argc, char **argv) { } cout << "Mounted " << (storage ? "SD" : "NAND") << " storage" << endl; - Config conf = Config::load(); string tmpItem, lastItem = getLastAlbumItem(conf); cout << "Current last item: " << lastItem << endl; diff --git a/src/project.h b/src/project.h index 8635e32..e5512fc 100644 --- a/src/project.h +++ b/src/project.h @@ -3,9 +3,9 @@ #define APP_TITLE "screenuploader" #define APP_AUTHOR "bakatrouble" -#define APP_VERSION "0.0.8" +#define APP_VERSION "0.0.10" #define VERSION_MAJOR "0" #define VERSION_MINOR "0" -#define VERSION_MICRO "8" +#define VERSION_MICRO "10" #endif // INCLUDE_GUARD