mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-13 02:32:56 +01: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) {
|
void initializeLogging(LogWorker* bgworker) {
|
||||||
std::call_once(g_initialize_flag, []() {
|
std::call_once(g_initialize_flag, []() {
|
||||||
installCrashHandler(); });
|
installCrashHandler();
|
||||||
|
});
|
||||||
std::lock_guard<std::mutex> lock(g_logging_init_mutex);
|
std::lock_guard<std::mutex> lock(g_logging_init_mutex);
|
||||||
CHECK(!internal::isLoggingInitialized());
|
CHECK(!internal::isLoggingInitialized());
|
||||||
CHECK(bgworker != nullptr);
|
CHECK(bgworker != nullptr);
|
||||||
|
@ -48,7 +48,7 @@ namespace g2 {
|
|||||||
void setLogLevel(LEVELS log_level, bool enabled) {
|
void setLogLevel(LEVELS log_level, bool enabled) {
|
||||||
assert(internal::g_level_size == 4 && "Mismatch between number of logging levels and their use");
|
assert(internal::g_level_size == 4 && "Mismatch between number of logging levels and their use");
|
||||||
int level = log_level.value;
|
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);
|
internal::g_log_level_status[level].store(enabled, std::memory_order_release);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -56,7 +56,7 @@ namespace g2 {
|
|||||||
bool logLevel(LEVELS log_level) {
|
bool logLevel(LEVELS log_level) {
|
||||||
#ifdef G2_DYNAMIC_LOGGING
|
#ifdef G2_DYNAMIC_LOGGING
|
||||||
int level = log_level.value;
|
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));
|
bool status = (internal::g_log_level_status[level].load(std::memory_order_acquire));
|
||||||
return status;
|
return status;
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +40,9 @@ struct LEVELS {
|
|||||||
|
|
||||||
LEVELS(int id, const char* idtext) : value(id), text(idtext) {}
|
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 int value;
|
||||||
const std::string text;
|
const std::string text;
|
||||||
@ -48,14 +50,20 @@ struct LEVELS {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace g2 {
|
||||||
static const int kDebugVaulue = 0;
|
static const int kDebugVaulue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if (defined(CHANGE_G3LOG_DEBUG_TO_DBUG))
|
#if (defined(CHANGE_G3LOG_DEBUG_TO_DBUG))
|
||||||
const LEVELS DBUG{kDebugVaulue, {"DEBUG"}},
|
const LEVELS DBUG {
|
||||||
|
g2::kDebugVaulue, {"DEBUG"}
|
||||||
|
},
|
||||||
#else
|
#else
|
||||||
const LEVELS DEBUG{kDebugVaulue, {"DEBUG"}},
|
const LEVELS DEBUG {
|
||||||
|
g2::kDebugVaulue, {"DEBUG"}
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
INFO{kDebugVaulue + 1, {"INFO"}},
|
INFO {g2::kDebugVaulue + 1, {"INFO"}},
|
||||||
WARNING {INFO.value + 1, {"WARNING"}},
|
WARNING {INFO.value + 1, {"WARNING"}},
|
||||||
// Insert here *any* extra logging levels that is needed
|
// Insert here *any* extra logging levels that is needed
|
||||||
// 1) Remember to update the FATAL initialization below
|
// 1) Remember to update the FATAL initialization below
|
||||||
@ -65,7 +73,9 @@ FATAL{WARNING.value + 1, {"FATAL"}};
|
|||||||
|
|
||||||
namespace g2 {
|
namespace g2 {
|
||||||
namespace internal {
|
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"}};
|
FATAL_EXCEPTION {102, {"FATAL_EXCEPTION"}};
|
||||||
bool wasFatal(const LEVELS& level);
|
bool wasFatal(const LEVELS& level);
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,26 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#if defined(G2LOG_PERFORMANCE)
|
#if defined(G2LOG_PERFORMANCE)
|
||||||
const std::string title{"G2LOG"};
|
const std::string title {
|
||||||
|
"G2LOG"
|
||||||
|
};
|
||||||
#elif defined(GOOGLE_GLOG_PERFORMANCE)
|
#elif defined(GOOGLE_GLOG_PERFORMANCE)
|
||||||
const std::string title{"GOOGLE__GLOG"};
|
const std::string title {
|
||||||
|
"GOOGLE__GLOG"
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
#error G2LOG_PERFORMANCE or GOOGLE_GLOG_PERFORMANCE was not defined
|
#error G2LOG_PERFORMANCE or GOOGLE_GLOG_PERFORMANCE was not defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
|
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
|
||||||
const std::string g_path{"./"};
|
const std::string g_path {
|
||||||
|
"./"
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
const std::string g_path{"/tmp/"};
|
const std::string g_path {
|
||||||
|
"/tmp/"
|
||||||
|
};
|
||||||
#endif
|
#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_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_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 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_ms {
|
||||||
const uint64_t us_to_s{1000000};
|
1000
|
||||||
|
};
|
||||||
|
const uint64_t us_to_s {
|
||||||
|
1000000
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "\n\n" << title << " performance " << number_of_threads << " threads WORST (PEAK) times\n";
|
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
|
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;
|
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);
|
writeTextToFile(g_measurement_dump, oss.str(), kAppend);
|
||||||
oss.str(""); // clear the stream
|
oss.str(""); // clear the stream
|
||||||
|
Loading…
Reference in New Issue
Block a user