diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-01-15 20:31:16 -0500 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-01-15 20:31:16 -0500 |
commit | ac7df193ca47261c2dfd91b230489e20955013a2 (patch) | |
tree | e4d312059948a0528583e7ea58d2c0b40307a494 /src/common/perf_timer.h | |
parent | Merge pull request #1578 (diff) | |
parent | Change logging to easylogging++ (diff) | |
download | monero-ac7df193ca47261c2dfd91b230489e20955013a2.tar.xz |
Merge pull request #1522
5833d66f Change logging to easylogging++ (moneromooo-monero)
dc98019b easylogging++: fix logging with static const header only data members (moneromooo-monero)
3b46617b easylogging++: add ELPP_DISABLE_CHECK_MACROS (moneromooo-monero)
6fe39d90 easylogging++: allow clipping a common filename prefix (moneromooo-monero)
43abf6ff easylogging++: add file-only logs (moneromooo-monero)
c313bea4 eayslogging++: Fix bad memory access before opening any files (moneromooo-monero)
0af5d168 easylogging++: avoid creating directory/filename for the builtin default log file (moneromooo-monero)
28362847 easylogging++: allow setting thread names (moneromooo-monero)
ec71ce8d easylogging++: Print thread ID in a nicer way (moneromooo-monero)
2a0bf783 easylogging++: Add logging categories (moneromooo-monero)
c50bbbfe easylogging++: import upstream (moneromooo-monero)
Diffstat (limited to 'src/common/perf_timer.h')
-rw-r--r-- | src/common/perf_timer.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h index 5eb5aaaec..56662ff24 100644 --- a/src/common/perf_timer.h +++ b/src/common/perf_timer.h @@ -32,23 +32,26 @@ #include <stdio.h> #include "misc_log_ex.h" +#undef MONERO_DEFAULT_LOG_CATEGORY +#define MONERO_DEFAULT_LOG_CATEGORY "perf" + namespace tools { class PerformanceTimer; -extern int performance_timer_log_level; +extern el::Level performance_timer_log_level; extern __thread std::vector<PerformanceTimer*> *performance_timers; class PerformanceTimer { public: - PerformanceTimer(const std::string &s, int l = LOG_LEVEL_2): name(s), level(l), started(false) + PerformanceTimer(const std::string &s, el::Level l = el::Level::Debug): name(s), level(l), started(false) { ticks = epee::misc_utils::get_tick_count(); if (!performance_timers) { - LOG_PRINT("PERF ----------", level); + MLOG(level, "PERF ----------"); performance_timers = new std::vector<PerformanceTimer*>(); } else @@ -56,7 +59,7 @@ public: PerformanceTimer *pt = performance_timers->back(); if (!pt->started) { - LOG_PRINT("PERF " << std::string((performance_timers->size()-1) * 2, ' ') << " " << pt->name, pt->level); + MLOG(pt->level, "PERF " << std::string((performance_timers->size()-1) * 2, ' ') << " " << pt->name); pt->started = true; } } @@ -69,7 +72,7 @@ public: ticks = epee::misc_utils::get_tick_count() - ticks; char s[12]; snprintf(s, sizeof(s), "%8llu ", (unsigned long long)ticks); - LOG_PRINT("PERF " << s << std::string(performance_timers->size() * 2, ' ') << " " << name, level); + MLOG(level, "PERF " << s << std::string(performance_timers->size() * 2, ' ') << " " << name); if (performance_timers->empty()) { delete performance_timers; @@ -79,12 +82,12 @@ public: private: std::string name; - int level; + el::Level level; uint64_t ticks; bool started; }; -void set_performance_timer_log_level(int level); +void set_performance_timer_log_level(el::Level level); #define PERF_TIMER(name) tools::PerformanceTimer pt_##name(#name, tools::performance_timer_log_level) #define PERF_TIMER_L(name, l) tools::PerformanceTimer pt_##name(#name, l) |