switch_text_channel_t channel;
switch_log_level_t slevel;
switch_event_t *tags;
+ /* Log sequence */
+ int64_t sequence;
} switch_log_node_t;
///\{
switch_log_json_format_item_t short_message;
const char *custom_field_prefix;
double timestamp_divisor;
+ switch_log_json_format_item_t sequence;
} switch_log_json_format_t;
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
{ "message", NULL }, // full_message
{ NULL, NULL }, // short_message
"", // custom_field_prefix
- 0.0 // timestamp_divisor
+ 0.0, // timestamp_divisor
+ { "sequence", NULL } // sequence
};
static char *to_json_string(const switch_log_node_t *node)
json_format.full_message.name = zstr(val) ? NULL : switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "short-message")) {
json_format.short_message.name = zstr(val) ? NULL : switch_core_strdup(module_pool, val);
+ } else if (!strcasecmp(var, "sequence")) {
+ json_format.sequence.name = zstr(val) ? NULL : switch_core_strdup(module_pool, val);
}
}
for (param = switch_xml_child(settings, "config"); param; param = param->next) {
globals.gelf_format.full_message.name = "full_message";
globals.gelf_format.short_message.name = "short_message";
globals.gelf_format.custom_field_prefix = "_";
+ globals.gelf_format.sequence.name = "_sequence";
switch_event_create_plain(&globals.session_fields, SWITCH_EVENT_CHANNEL_DATA);
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;
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 == ' ') {
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);