FS-11870 [core, mod_graylog2, mod_console] Added switch_log_node_to_json() and updated mod_graylog2 to use it. This is a unified log node to JSON conversion.

Added json log mode in mod_console
This commit is contained in:
Chris Rienzo
2019-05-30 12:37:04 -04:00
committed by Andrey Volk
parent 302b409815
commit b06c7b0831
4 changed files with 294 additions and 103 deletions
+36
View File
@@ -68,8 +68,44 @@ SWITCH_BEGIN_EXTERN_C
switch_event_t *tags;
} switch_log_node_t;
///\{
/*! \brief JSON Log formatting data item
*/
typedef struct {
const char *name;
const char *value;
} switch_log_json_format_item_t;
///\{
/*! \brief JSON Log formatting data
*/
typedef struct {
switch_log_json_format_item_t version;
switch_log_json_format_item_t host;
switch_log_json_format_item_t timestamp;
switch_log_json_format_item_t level;
switch_log_json_format_item_t ident;
switch_log_json_format_item_t pid;
switch_log_json_format_item_t uuid;
switch_log_json_format_item_t file;
switch_log_json_format_item_t line;
switch_log_json_format_item_t function;
switch_log_json_format_item_t full_message;
switch_log_json_format_item_t short_message;
const char *custom_field_prefix;
double timestamp_divisor;
} switch_log_json_format_t;
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
/*!
\brief Convert a log node to JSON object. Destroy JSON object when finished.
\param node the node
\param log_level the log level
\param json_format the output format definition
\param char_vars optional channel variables to add to logs
*/
SWITCH_DECLARE(cJSON *) switch_log_node_to_json(const switch_log_node_t *node, int log_level, switch_log_json_format_t *json_format, switch_event_t *chan_vars);
/*!
\brief Initilize the logging engine