59 {
60 try {
64
65 std::lock_guard g( log_config::get().log_mutex );
66 log_config::get().logger_map.clear();
67 log_config::get().appender_map.clear();
68
69 for( size_t i = 0; i < cfg.appenders.size(); ++i ) {
70
71 auto fact_itr = log_config::get().appender_factory_map.find( cfg.appenders[i].type );
72 if( fact_itr == log_config::get().appender_factory_map.end() ) {
73
74 continue;
75 }
76 auto ap = fact_itr->second->create( cfg.appenders[i].args );
77 log_config::get().appender_map[cfg.appenders[i].name] = ap;
78 }
79 for( size_t i = 0; i < cfg.loggers.size(); ++i ) {
80 auto lgr = log_config::get().logger_map[cfg.loggers[i].name];
81
82
83 if( cfg.loggers[i].parent ) {
84 lgr.set_parent( log_config::get().logger_map[*cfg.loggers[i].parent] );
85 }
86 lgr.set_name(cfg.loggers[i].name);
87 if( cfg.loggers[i].level ) lgr.set_log_level( *cfg.loggers[i].level );
88
89
90 for(
auto a = cfg.loggers[i].appenders.begin();
a != cfg.loggers[i].appenders.end(); ++
a ){
91 auto ap_it = log_config::get().appender_map.find(*
a);
92 if( ap_it != log_config::get().appender_map.end() ) {
93 lgr.add_appender( ap_it->second );
94 }
95 }
96 }
97 return reg_console_appender || reg_gelf_appender || reg_dmlog_appender;
98 } catch ( exception& e )
99 {
100 std::cerr<<e.to_detail_string()<<"\n";
101 }
102 return false;
103 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
static bool register_appender(const fc::string &type)