1.easylogging源码学习笔记(6)
easylogging源码学习笔记(6)
`LOG` 是源码默认日志、CLOG自定义日志、源码LOG_IF条件日志
特殊日志
LOG_EVERY_N、源码LOG_AFTER_N、源码编辑html源码LOG_N_TIMES
for (int i = 1; i <= ; ++i) {
LOG_EVERY_N(2,源码 INFO) << "Logged every second iter";
}// 5 logs written; 2, 4, 6, 7,
for (int i = 1; i <= ; ++i) {
LOG_AFTER_N(2, INFO) << "Log after 2 hits; " << i;
}// 8 logs written; 3, 4, 5, 6, 7, 8, 9,
for (int i = 1; i <= ; ++i) {
LOG_N_TIMES(3, INFO) << "Log only 3 times; " << i;
}// 3 logs writter; 1, 2, 3
条件日志和特殊日志可以搭配使用
* `VLOG_IF(condition, verbose-level)`
* `CVLOG_IF(condition, verbose-level, loggerID)`
* `VLOG_EVERY_N(n, verbose-level)`
* `CVLOG_EVERY_N(n, verbose-level, loggerID)`
* `VLOG_AFTER_N(n, verbose-level)`
* `CVLOG_AFTER_N(n, verbose-level, loggerID)`
* `VLOG_N_TIMES(n, verbose-level)`
* `CVLOG_N_TIMES(n, verbose-level, loggerID)`
日志详细等级判定
if (VLOG_IS_ON(2)) {
// Verbosity level 2 is on for this file
}
性能追踪
* `TIMED_FUNC(obj-name)`
* `TIMED_SCOPE(obj-name, block-name)`
* `TIMED_BLOCK(obj-name, block-name)`
这些宏实际上都是关于el::base::type::PerformanceTrackerPtr,一个指向el::base::PerformanceTracker的源码指标报警源码指针
#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
PerformanceTracker::PerformanceTracker(const std::string& blockName,
base::TimestampUnit timestampUnit,
const std::string& loggerId,
bool scopedLog, Level level) :
m_blockName(blockName), m_timestampUnit(timestampUnit), m_loggerId(loggerId), m_scopedLog(scopedLog),
m_level(level), m_hasChecked(false), m_lastCheckpointId(std::string()), m_enabled(false) {
#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
// We store it locally so that if user happen to change configuration by the end of scope
// or before calling checkpoint, we still depend on state of configuration at time of construction
el::Logger* loggerPtr = ELPP->registeredLoggers()->get(loggerId, false);
m_enabled = loggerPtr != nullptr && loggerPtr->m_typedConfigurations->performanceTracking(m_level);
if (m_enabled) {
base::utils::DateTime::gettimeofday(&m_startTime);
}
#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
}
在构造函数中获取一个时间,
PerformanceTracker::~PerformanceTracker(void) {
#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
if (m_enabled) {
base::threading::ScopedLock scopedLock(lock());
if (m_scopedLog) {
base::utils::DateTime::gettimeofday(&m_endTime);
base::type::string_t formattedTime = getFormattedTimeTaken();
PerformanceTrackingData data(PerformanceTrackingData::DataType::Complete);
data.init(this);
data.m_formattedTimeTaken = formattedTime;
PerformanceTrackingCallback* callback = nullptr;
for (const std::pair& h
: ELPP->m_performanceTrackingCallbacks) {
callback = h.second.get();
if (callback != nullptr && callback->enabled()) {
callback->handle(&data);
}
}
}
}
#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING)
}
在析构函数中获取一个时间,源码处理时间data,源码使用PerformanceTrackingCallback类型指针callback,源码并在callback->handle(&data)中处理输出。源码
由于定义了ELPP_FEATURE_PERFORMANCE_TRACKING,源码因此在初始化(INITIALIZE_EASYLOGGINGPP)中实际上是源码安装了一个base::DefaultPerformanceTrackingCallback。
在PerformanceTracker类的源码dllimport用法源码handle函数中,callback是源码一个PerformanceTrackingCallback类型指针,由于安装的源码是DefaultPerformanceTrackingCallback对象,因此是悟空看书源码一个基类指针指向了派生类对象。处理输出的逻辑在DefaultPerformanceTrackingCallback类的handle函数中。
DefaultPerformanceTrackingCallback类的handle函数首先会将数据成员m_data的指针赋值给函数参数,并创建一个base::type::stringstream_t类型的项目案例源码对象ss用于构建输出内容。根据m_data的dataType,输出不同的信息。在输出时,会使用el::base::Writer类构造并输出内容。
2024-12-23 07:15769人浏览
2024-12-23 06:46552人浏览
2024-12-23 06:371065人浏览
2024-12-23 06:34558人浏览
2024-12-23 06:271590人浏览
2024-12-23 06:131983人浏览
南投中寮石龍宮有泡麵土地公之稱,今8/1)天凌晨2點多,不明原因發生大火,整間廟全面燃燒陷入火海,還傳出爆炸聲響,嚇得香客們丟下泡麵緊急逃生。熱心民眾想幫忙滅火 現場找不到滅火器以拜泡麵、吃泡麵而聞名
1.【量化干货02】收集过的交易开拓者TB量化投资程序化交易资料合集【量化干货02】收集过的交易开拓者TB量化投资程序化交易资料合集 交易开拓者(TradeBlazer)作为专业投资者的交易软件,
1.有没有免费的ASP源码?后台可全站操作的2.谁有免费的**网站源代码?有没有免费的ASP源码?后台可全站操作的 免费的源码有啊,只不过你没有好好的,找比如www.CHINAZ.COM 这上面就