...
 
Commits (2)
......@@ -44,3 +44,6 @@ connection = TRACE
# This is the "main" logger for C++, if no specific one is used. It is also the default for all applications.
app = TRACE
# AgoRPC is pretty verbose with low-level debugging in TRACE mode.
httpd = DEBUG
\ No newline at end of file
This diff is collapsed.
......@@ -118,5 +118,26 @@ const std::vector<std::string>& log_container::getLevels() {
return log_levels;
}
/**
* Get the default initial log level, by looking at the AGO_DEFAULT_LEVEL env var.
* If set, and valid, this is used instead of the default INFO level.
*
* This can be used to debug config loading or logging setup which happens before
* any custom logging level have been set.
*
* @return
*/
severity_level log_container::getDefaultLevel() {
const char* env_level = getenv("AGO_DEFAULT_LEVEL");
if(env_level) {
try {
return getLevel(env_level);
}catch(const std::runtime_error& e) {
std::cerr << "Ignoring invalid value in env AGO_DEFAULT_LEVEL" << std::endl;
}
}
return ::agocontrol::log::info;
}
}/* namespace log */
}/* namespace agocontrol */
......@@ -37,7 +37,6 @@ namespace agocontrol {
}
}
#define AGO_DEFAULT_LEVEL ::agocontrol::log::info
#ifdef HAVE_BOOST_LOG
# include <agolog_boost.h>
......@@ -91,6 +90,9 @@ public:
/* Returns a vector with all levels, indexed identical to severity_level */
static const std::vector<std::string> & getLevels();
protected:
static severity_level getDefaultLevel();
};
} /* namespace log */
......
......@@ -121,7 +121,7 @@ class simple_logger {
public:
simple_logger()
: current_level(AGO_DEFAULT_LEVEL)
: current_level(getDefaultLevel())
, sink( boost::shared_ptr<log_sink>(new console_sink()) )
{}
......
......@@ -80,7 +80,7 @@ void log_container::initDefault() {
logging::add_common_attributes();
setOutputConsole();
setCurrentLevel(AGO_DEFAULT_LEVEL, std::map<std::string, severity_level>());
setCurrentLevel(getDefaultLevel(), std::map<std::string, severity_level>());
// Setup exception handler
logging::core::get()->set_exception_handler(logging::make_exception_handler<
......