|
|
@ -614,6 +614,15 @@ class MonitoringSpdLoggerConfigTask { |
|
|
|
}; |
|
|
|
|
|
|
|
shared_ptr<logger> SpdLoggerFactory::createLogger(string loggerName) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* 如果在main函数之前就创建了logger,会导致部分全局变量未初始化 |
|
|
|
*/ |
|
|
|
if (default_config.empty()) { |
|
|
|
spdlog::critical("you may construct a logger {} before main!!", loggerName); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
spdlog::critical("create {}", loggerName); |
|
|
|
lock_guard<mutex> lock_gu(createLogger_lock); |
|
|
|
if (!loggerName.empty()) { |
|
|
|
if (s_loggerNames.size() == 0) { |
|
|
@ -633,10 +642,6 @@ shared_ptr<logger> SpdLoggerFactory::createLogger(string loggerName) { |
|
|
|
} |
|
|
|
|
|
|
|
if (!initializeLogger) { |
|
|
|
if (default_config.empty()) { |
|
|
|
spdlog::warn("you may construct a logger before main!!"); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
string configFilePath = getConfigFilePath(); |
|
|
|
if (!configFilePath.empty() && exist(configFilePath)) { |
|
|
|
parseSphLogConfig(configFilePath); |
|
|
|