Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide default log level of info for non-configured loggers. #110

Merged
merged 7 commits into from
Aug 22, 2019
Merged
12 changes: 6 additions & 6 deletions include/fc/log/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include <fc/time.hpp>
#include <fc/log/log_message.hpp>

namespace fc
#ifndef DEFAULT_LOGGER
#define DEFAULT_LOGGER "default"
#endif

namespace fc
{

class appender;
Expand All @@ -21,7 +25,7 @@ namespace fc
class logger
{
public:
static logger get( const fc::string& name = "default");
static logger get( const fc::string& name = DEFAULT_LOGGER );
arhag marked this conversation as resolved.
Show resolved Hide resolved
static void update( const fc::string& name, logger& log );

logger();
Expand Down Expand Up @@ -57,10 +61,6 @@ namespace fc

} // namespace fc

#ifndef DEFAULT_LOGGER
#define DEFAULT_LOGGER
#endif

// suppress warning "conditional expression is constant" in the while(0) for visual c++
// http://cnicholson.net/2009/03/stupid-c-tricks-dowhile0-and-c4127/
#define FC_MULTILINE_MACRO_BEGIN do {
Expand Down
7 changes: 6 additions & 1 deletion src/log/logger_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ namespace fc {

void log_config::update_logger( const fc::string& name, logger& log ) {
std::lock_guard g( log_config::get().log_mutex );
if( log_config::get().logger_map.find( name ) != log_config::get().logger_map.end() )
if( log_config::get().logger_map.find( name ) != log_config::get().logger_map.end() ) {
log = log_config::get().logger_map[name];
} else {
// no entry for logger, so setup with log_config's registered appenders
log = log_config::get().logger_map[ DEFAULT_LOGGER ];
arhag marked this conversation as resolved.
Show resolved Hide resolved
log_config::get().logger_map.emplace( name, log );
}
}

void log_config::initialize_appenders( boost::asio::io_service& ios ) {
Expand Down