mirror of
https://github.com/KjellKod/g3log.git
synced 2025-07-03 09:15:22 +02:00
Finally the right sublime AstyleFormat options pointer-align:type and reference-align:type
Fixed bug with dynamic logging levels and DBUG (instead of DEBUG)
This commit is contained in:
parent
fb30aef9e8
commit
c5bb9b96d8
@ -53,7 +53,8 @@ namespace g2 {
|
||||
|
||||
void initializeLogging(LogWorker* bgworker) {
|
||||
std::call_once(g_initialize_flag, []() {
|
||||
installCrashHandler(); });
|
||||
installCrashHandler();
|
||||
});
|
||||
std::lock_guard<std::mutex> lock(g_logging_init_mutex);
|
||||
CHECK(!internal::isLoggingInitialized());
|
||||
CHECK(bgworker != nullptr);
|
||||
|
@ -48,7 +48,7 @@ namespace g2 {
|
||||
void setLogLevel(LEVELS log_level, bool enabled) {
|
||||
assert(internal::g_level_size == 4 && "Mismatch between number of logging levels and their use");
|
||||
int level = log_level.value;
|
||||
CHECK((level >= DEBUG.value) && (level <= FATAL.value));
|
||||
CHECK((level >= g2::kDebugVaulue) && (level <= FATAL.value));
|
||||
internal::g_log_level_status[level].store(enabled, std::memory_order_release);
|
||||
}
|
||||
#endif
|
||||
@ -56,7 +56,7 @@ namespace g2 {
|
||||
bool logLevel(LEVELS log_level) {
|
||||
#ifdef G2_DYNAMIC_LOGGING
|
||||
int level = log_level.value;
|
||||
CHECK((level >= DEBUG.value) && (level <= FATAL.value));
|
||||
CHECK((level >= g2::kDebugVaulue) && (level <= FATAL.value));
|
||||
bool status = (internal::g_log_level_status[level].load(std::memory_order_acquire));
|
||||
return status;
|
||||
#endif
|
||||
|
@ -40,7 +40,9 @@ struct LEVELS {
|
||||
|
||||
LEVELS(int id, const char* idtext) : value(id), text(idtext) {}
|
||||
|
||||
friend bool operator==(const LEVELS & lhs, const LEVELS & rhs) { return (lhs.value == rhs.value && lhs.text == rhs.text); }
|
||||
friend bool operator==(const LEVELS& lhs, const LEVELS& rhs) {
|
||||
return (lhs.value == rhs.value && lhs.text == rhs.text);
|
||||
}
|
||||
|
||||
const int value;
|
||||
const std::string text;
|
||||
@ -48,14 +50,20 @@ struct LEVELS {
|
||||
|
||||
|
||||
|
||||
|
||||
namespace g2 {
|
||||
static const int kDebugVaulue = 0;
|
||||
}
|
||||
|
||||
#if (defined(CHANGE_G3LOG_DEBUG_TO_DBUG))
|
||||
const LEVELS DBUG{kDebugVaulue, {"DEBUG"}},
|
||||
const LEVELS DBUG {
|
||||
g2::kDebugVaulue, {"DEBUG"}
|
||||
},
|
||||
#else
|
||||
const LEVELS DEBUG{kDebugVaulue, {"DEBUG"}},
|
||||
const LEVELS DEBUG {
|
||||
g2::kDebugVaulue, {"DEBUG"}
|
||||
},
|
||||
#endif
|
||||
INFO{kDebugVaulue + 1, {"INFO"}},
|
||||
INFO {g2::kDebugVaulue + 1, {"INFO"}},
|
||||
WARNING {INFO.value + 1, {"WARNING"}},
|
||||
// Insert here *any* extra logging levels that is needed
|
||||
// 1) Remember to update the FATAL initialization below
|
||||
@ -65,7 +73,9 @@ FATAL{WARNING.value + 1, {"FATAL"}};
|
||||
|
||||
namespace g2 {
|
||||
namespace internal {
|
||||
const LEVELS CONTRACT{100, {"CONTRACT"}}, FATAL_SIGNAL{101, {"FATAL_SIGNAL"}},
|
||||
const LEVELS CONTRACT {
|
||||
100, {"CONTRACT"}
|
||||
}, FATAL_SIGNAL {101, {"FATAL_SIGNAL"}},
|
||||
FATAL_EXCEPTION {102, {"FATAL_EXCEPTION"}};
|
||||
bool wasFatal(const LEVELS& level);
|
||||
}
|
||||
|
@ -16,18 +16,26 @@
|
||||
#include <cmath>
|
||||
|
||||
#if defined(G2LOG_PERFORMANCE)
|
||||
const std::string title{"G2LOG"};
|
||||
const std::string title {
|
||||
"G2LOG"
|
||||
};
|
||||
#elif defined(GOOGLE_GLOG_PERFORMANCE)
|
||||
const std::string title{"GOOGLE__GLOG"};
|
||||
const std::string title {
|
||||
"GOOGLE__GLOG"
|
||||
};
|
||||
#else
|
||||
#error G2LOG_PERFORMANCE or GOOGLE_GLOG_PERFORMANCE was not defined
|
||||
#endif
|
||||
|
||||
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
|
||||
const std::string g_path{"./"};
|
||||
const std::string g_path {
|
||||
"./"
|
||||
};
|
||||
#else
|
||||
const std::string g_path{"/tmp/"};
|
||||
const std::string g_path {
|
||||
"/tmp/"
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@ -57,14 +65,20 @@ int main(int argc, char** argv)
|
||||
const std::string g_prefix_log_name = title + "-performance-" + thread_count_oss.str() + "threads-WORST_LOG";
|
||||
const std::string g_measurement_dump = g_path + g_prefix_log_name + "_RESULT.txt";
|
||||
const std::string g_measurement_bucket_dump = g_path + g_prefix_log_name + "_RESULT_buckets.txt";
|
||||
const uint64_t us_to_ms{1000};
|
||||
const uint64_t us_to_s{1000000};
|
||||
const uint64_t us_to_ms {
|
||||
1000
|
||||
};
|
||||
const uint64_t us_to_s {
|
||||
1000000
|
||||
};
|
||||
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "\n\n" << title << " performance " << number_of_threads << " threads WORST (PEAK) times\n";
|
||||
oss << "Each thread running #: " << g_loop << " * " << g_iterations << " iterations of log entries" << std::endl; // worst mean case is about 10us per log entry
|
||||
const uint64_t xtra_margin{2};
|
||||
const uint64_t xtra_margin {
|
||||
2
|
||||
};
|
||||
oss << "*** It can take som time. Please wait: Approximate wait time on MY PC was: " << number_of_threads * (uint64_t)(g_iterations * 10 * xtra_margin / us_to_s) << " seconds" << std::endl;
|
||||
writeTextToFile(g_measurement_dump, oss.str(), kAppend);
|
||||
oss.str(""); // clear the stream
|
||||
|
Loading…
x
Reference in New Issue
Block a user