[core, mod_console, mod_graylog2] Add sequence to logs to preserve order when timestamp is not precise enough.

This commit is contained in:
Chris Rienzo authored and Andrey Volk committed 2021-10-23 22:00:34 +03:00
1 parent cd041b768c
commit 2c3dcbde71
4 files changed
+14 -1

No files matched your search

+6
View File
@@ -68,6 +68,8 @@ static int mods_loaded = 0;
static int console_mods_loaded = 0;
static switch_bool_t COLORIZE = SWITCH_FALSE;
static int64_t log_sequence = 0;
#ifdef WIN32
static HANDLE hStdout;
static WORD wOldColorAttrs;
@@ -144,6 +146,9 @@ SWITCH_DECLARE(cJSON *) switch_log_node_to_json(const switch_log_node_t *node, i
if (json_format->function.name && !zstr_buf(node->func)) {
cJSON_AddItemToObject(json, json_format->function.name, cJSON_CreateString(node->func));
}
if (json_format->sequence.name) {
cJSON_AddItemToObject(json, json_format->sequence.name, cJSON_CreateNumber(node->sequence));
}
/* skip initial space and new line */
if (*full_message == ' ') {
@@ -478,6 +483,7 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *t, void *obj)
node = (switch_log_node_t *) pop;
switch_mutex_lock(BINDLOCK);
node->sequence = ++log_sequence;
for (binding = BINDINGS; binding; binding = binding->next) {
if (binding->level >= node->level) {
binding->function(node, node->level);