Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::log_config Struct Reference

#include <logger_config.hpp>

Static Public Member Functions

template<typename T >
static bool register_appender (const fc::string &type)
 
static bool register_appender (const fc::string &type, const appender_factory::ptr &f)
 
static logger get_logger (const fc::string &name)
 
static void update_logger (const fc::string &name, logger &log)
 
static void initialize_appenders (boost::asio::io_service &ios)
 
static bool configure_logging (const logging_config &l)
 

Friends

class logger
 

Detailed Description

Definition at line 45 of file logger_config.hpp.

Member Function Documentation

◆ configure_logging()

bool fc::log_config::configure_logging ( const logging_config & l)
static

Definition at line 59 of file logger_config.cpp.

59 {
60 try {
61 static bool reg_console_appender = log_config::register_appender<console_appender>( "console" );
62 static bool reg_gelf_appender = log_config::register_appender<gelf_appender>( "gelf" );
63 static bool reg_dmlog_appender = log_config::register_appender<dmlog_appender>( "dmlog" );
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 // create appender
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 //wlog( "Unknown appender type '%s'", type.c_str() );
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 // TODO: finish configure logger here...
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
Definition pointer.h:1181
static bool register_appender(const fc::string &type)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_logger()

logger fc::log_config::get_logger ( const fc::string & name)
static

Definition at line 28 of file logger_config.cpp.

28 {
29 std::lock_guard g( log_config::get().log_mutex );
30 return log_config::get().logger_map[name];
31 }
std::string name
Here is the caller graph for this function:

◆ initialize_appenders()

void fc::log_config::initialize_appenders ( boost::asio::io_service & ios)
static

Definition at line 46 of file logger_config.cpp.

46 {
47 std::lock_guard g( log_config::get().log_mutex );
48 for( auto& iter : log_config::get().appender_map )
49 iter.second->initialize( ios );
50 }
Here is the caller graph for this function:

◆ register_appender() [1/2]

template<typename T >
static bool fc::log_config::register_appender ( const fc::string & type)
inlinestatic

Definition at line 48 of file logger_config.hpp.

48 {
49 return register_appender( type, std::make_shared<detail::appender_factory_impl<T>>() );
50 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_appender() [2/2]

bool fc::log_config::register_appender ( const fc::string & type,
const appender_factory::ptr & f )
static

Definition at line 21 of file logger_config.cpp.

22 {
23 std::lock_guard g( log_config::get().log_mutex );
24 log_config::get().appender_factory_map[type] = f;
25 return true;
26 }
yh_object_type type
Definition yubihsm.h:672

◆ update_logger()

void fc::log_config::update_logger ( const fc::string & name,
logger & log )
static

Definition at line 33 of file logger_config.cpp.

33 {
34 std::lock_guard g( log_config::get().log_mutex );
35 if( log_config::get().logger_map.find( name ) != log_config::get().logger_map.end() ) {
36 log = log_config::get().logger_map[name];
37 } else {
38 // no entry for logger, so setup with default logger if it exists, otherwise do nothing since default logger not configured
39 if( log_config::get().logger_map.find( DEFAULT_LOGGER ) != log_config::get().logger_map.end() ) {
40 log = log_config::get().logger_map[DEFAULT_LOGGER];
41 log_config::get().logger_map.emplace( name, log );
42 }
43 }
44 }
#define DEFAULT_LOGGER
Definition logger.hpp:7
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ logger

friend class logger
friend

Definition at line 64 of file logger_config.hpp.


The documentation for this struct was generated from the following files: