Wallet API: allow log path to be non-default & console output to be configurable

This commit is contained in:
stoffu 2018-05-02 11:46:46 +09:00 committed by wowario
parent e303fd1e1d
commit cefad3cea8
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111
2 changed files with 4 additions and 3 deletions

View File

@ -305,14 +305,14 @@ uint64_t Wallet::maximumAllowedAmount()
return std::numeric_limits<uint64_t>::max(); return std::numeric_limits<uint64_t>::max();
} }
void Wallet::init(const char *argv0, const char *default_log_base_name) { void Wallet::init(const char *argv0, const char *default_log_base_name, const std::string &log_path, bool console) {
#ifdef WIN32 #ifdef WIN32
// Activate UTF-8 support for Boost filesystem classes on Windows // Activate UTF-8 support for Boost filesystem classes on Windows
std::locale::global(boost::locale::generator().generate("")); std::locale::global(boost::locale::generator().generate(""));
boost::filesystem::path::imbue(std::locale()); boost::filesystem::path::imbue(std::locale());
#endif #endif
epee::string_tools::set_module_name_and_folder(argv0); epee::string_tools::set_module_name_and_folder(argv0);
mlog_configure(mlog_get_default_log_path(default_log_base_name), true); mlog_configure(log_path.empty() ? mlog_get_default_log_path(default_log_base_name) : log_path.c_str(), console);
} }
void Wallet::debug(const std::string &category, const std::string &str) { void Wallet::debug(const std::string &category, const std::string &str) {

View File

@ -556,7 +556,8 @@ struct Wallet
} }
static uint64_t maximumAllowedAmount(); static uint64_t maximumAllowedAmount();
// Easylogger wrapper // Easylogger wrapper
static void init(const char *argv0, const char *default_log_base_name); static void init(const char *argv0, const char *default_log_base_name) { init(argv0, default_log_base_name, "", true); }
static void init(const char *argv0, const char *default_log_base_name, const std::string &log_path, bool console);
static void debug(const std::string &category, const std::string &str); static void debug(const std::string &category, const std::string &str);
static void info(const std::string &category, const std::string &str); static void info(const std::string &category, const std::string &str);
static void warning(const std::string &category, const std::string &str); static void warning(const std::string &category, const std::string &str);