]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add RINDENT_SAVE / RESTORE
authorAlan T. DeKok <aland@freeradius.org>
Fri, 16 Sep 2022 00:50:11 +0000 (20:50 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 16 Sep 2022 00:50:11 +0000 (20:50 -0400)
so that we can save indention, and then avoid REXDENT on all
of the error paths.

src/lib/server/log.h

index 14fddedd57a0d3e7c0e9d69fc9ba8d2fd9022fc4..d38b159d3300f7be5a3974a45b630b68802c07b7 100644 (file)
@@ -375,6 +375,28 @@ void       log_global_free(void);
 #define RPEDEBUG4(fmt, ...)    log_request_perror(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 /** @} */
 
+typedef struct {
+       uint8_t                 unlang_indent;  //!< By how much to indent log messages. uin8_t so it's obvious
+                                               //!< when a request has been exdented too much.
+       uint8_t                 module_indent;  //!< Indentation after the module prefix name.
+} rindent_t;
+
+/** Save indentation for later restoral.
+ *
+ *  This call avoids the need to manually REXDENT on error paths.  We
+ *  can just restore and return.
+ *
+ */
+#define RINDENT_SAVE(_x, _request) do { \
+               (_x)->unlang_indent = request->log.unlang_indent; \
+               (_x)->module_indent = request->log.module_indent; \
+       } while (0)
+
+#define RINDENT_RESTORE(_request, _x) do { \
+               request->log.unlang_indent = (_x)->unlang_indent; \
+               request->log.module_indent = (_x)->module_indent; \
+       } while (0)
+
 #ifdef DEBUG_INDENT
 /** Indent R* messages by one level
  *