Commit e115e4ed authored by Ivan Vilata-i-Balaguer's avatar Ivan Vilata-i-Balaguer
Browse files

Enable debugging when the log file is on.

Recover the log level once the log file is disabled (unless explicitly set by
the user while logging to the file).
parent 28776729
......@@ -162,12 +162,21 @@ void ClientFrontEnd::handle_ca_pem( const Request& req, Response& res, stringstr
ss << ca.pem_certificate();
}
static void enable_log_to_file(const std::string& path) {
void ClientFrontEnd::enable_log_to_file(const std::string& path) {
if (!_log_level_no_file) // not when changing active log file
_log_level_no_file = logger.get_threshold();
_log_level_input->current_value = DEBUG;
logger.set_threshold(DEBUG);
logger.log_to_file(path);
}
static void disable_log_to_file() {
void ClientFrontEnd::disable_log_to_file() {
logger.log_to_file("");
if (_log_level_no_file) {
logger.set_threshold(*_log_level_no_file);
_log_level_input->current_value = *_log_level_no_file;
_log_level_no_file = boost::none;
}
}
static void load_log_file(stringstream& out_ss) {
......@@ -204,6 +213,8 @@ void ClientFrontEnd::handle_portal( ClientConfig& config
if (_log_level_input->update(target)) {
logger.set_threshold(_log_level_input->current_value);
if (logger.get_log_file() != nullptr) // remember explicitly set level
_log_level_no_file = _log_level_input->current_value;
}
if (cache_client) {
......
......@@ -88,6 +88,7 @@ public:
private:
bool _auto_refresh_enabled = true;
bool _show_pending_tasks = false;
boost::optional<log_level_t> _log_level_no_file;
std::unique_ptr<Input<log_level_t>> _log_level_input;
std::unique_ptr<Input<log_level_t>> _cache_log_level_input;
......@@ -121,6 +122,10 @@ private:
, std::stringstream&
, cache::Client*
, Yield);
// Enabling the log file also enables debugging temporarily.
void enable_log_to_file(const std::string& path);
void disable_log_to_file();
};
} // ouinet namespace
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment