/*
* format_bufr[FORMAT_BUFR_SIZE - 1] should always be reserved
* for a terminating null byte.
+ *
+ * Note: The json logging unit tests lib/util/tests/test_json_logging.c
+ * assume this value is 4096, they'll need to be updated if
+ * this is changed
*/
#define FORMAT_BUFR_SIZE 4096
format_bufr[format_pos] = '\0';
}
+/***************************************************************************
+ Output a single line of JSON to the logs
+
+ Input: msg - text to be output
+
+ Output: none.
+
+ Notes: - msg is output without any added leading white space
+ - Any embedded "\n" characters are replaced with spaces
+ - A terminating "\n" is output.
+**************************************************************************/
+
+bool dbgjson( const char *msg )
+{
+ size_t i;
+ const char eol[] = "\n";
+
+ debug_init();
+
+ for( i = 0; msg[i]; i++ ) {
+ /* If the buffer is full output it */
+ if (format_pos >= FORMAT_BUFR_SIZE - 1) {
+ bufr_print();
+ }
+ /* replace any new lines with spaces*/
+ if( '\n' == msg[i] ) {
+ format_bufr[format_pos++] = ' ';
+ } else {
+ format_bufr[format_pos++] = msg[i];
+ }
+
+ }
+ if (format_pos > 0) {
+ bufr_print();
+ }
+ (void)Debug1(eol , sizeof(eol) - 1);
+
+ /* Just to be safe... */
+ format_bufr[format_pos] = '\0';
+ return true;
+}
+
/***************************************************************************
Flush debug output, including the format buffer content.
&& (dbgsetclass(level, dbgc_class)) \
&& (dbgtext body) )
+bool dbgjson( const char *msg );
+#define DEBUGJSON( level, line) \
+ (void) ( ((level) <= MAX_DEBUG_LEVEL) && \
+ unlikely(debuglevel_get_class(DBGC_CLASS) >= (level)) \
+ && (dbgsetclass(level, DBGC_CLASS)) \
+ && (dbgjson line) )
+
+#define DEBUGJSONC( dbgc_class, level, line) \
+ (void)( ((level) <= MAX_DEBUG_LEVEL) && \
+ unlikely((debuglevel_get_class(dbgc_class) >= (level))) \
+ && (dbgsetclass(level, dbgc_class)) \
+ && (dbgjson line) )
+
/* Print a separator to the debug log. */
#define DEBUGSEP(level)\
DEBUG((level),("===============================================================\n"))