]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
cache log level in log_dst_t and use it to skip logging destinations.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Nov 2023 19:55:39 +0000 (14:55 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Nov 2023 19:55:39 +0000 (14:55 -0500)
The idea is that we can add a debug destination, where debug messages
go.  But normal messages still get passed through to *both* the
debug destination, and to the normal destination.

That we can add debug logging, and still have normal messages
go to the normal log destination

src/lib/server/log.c
src/lib/server/log.h

index 73861e8f9f348ceb1683c5d742755f1d9a622791..cbe3ce13b81c9b44339a4ba0c6cfc227c0228f2d 100644 (file)
@@ -618,13 +618,15 @@ void log_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request,
                 char const *file, int line, char const *fmt, ...)
 {
        va_list         ap;
-       log_dst_t       *dst_p;
+       log_dst_t       *dst;
 
        if (!request->log.dst) return;
 
        va_start(ap, fmt);
-       for (dst_p = request->log.dst; dst_p; dst_p = dst_p->next) {
-               dst_p->func(type, lvl, request, file, line, fmt, ap, dst_p->uctx);
+       for (dst = request->log.dst; dst; dst = dst->next) {
+               if (lvl < dst->lvl) continue;
+
+               dst->func(type, lvl, request, file, line, fmt, ap, dst->uctx);
        }
        va_end(ap);
 }
index 7a645f60b145762fc197bdc4d562a0f298a29045..82acdde6d9803df33f4ee43fdd0d3031faaeb03a 100644 (file)
@@ -65,6 +65,7 @@ typedef       void (*log_func_t)(fr_log_type_t type, fr_log_lvl_t lvl, request_t *requ
 struct log_dst {
        log_func_t      func;           //!< Function to call to log to this destination.
        void            *uctx;          //!< Context to pass to the logging function.
+       fr_log_lvl_t    lvl;            //!< Log messages with lvl >= to this should be logged.
        log_dst_t       *next;          //!< Next logging destination.
 };