Remember filter log level.
authorArmin Novak <armin.novak@thincast.com>
Wed, 2 Mar 2016 18:02:01 +0000 (19:02 +0100)
committerArmin Novak <armin.novak@thincast.com>
Wed, 2 Mar 2016 18:07:32 +0000 (19:07 +0100)
winpr/libwinpr/utils/wlog/wlog.c
winpr/libwinpr/utils/wlog/wlog.h

index 87739e9..5a1742c 100644 (file)
@@ -538,9 +538,11 @@ BOOL WLog_ParseFilters(void)
 LONG WLog_GetFilterLogLevel(wLog* log)
 {
        DWORD i, j;
-       LONG iLevel = -1;
        BOOL match = FALSE;
 
+       if (log->FilterLevel >= 0)
+               return log->FilterLevel;
+
        for (i = 0; i < g_FilterCount; i++)
        {
                for (j = 0; j < g_Filters[i].NameCount; j++)
@@ -569,9 +571,11 @@ LONG WLog_GetFilterLogLevel(wLog* log)
        }
 
        if (match)
-               iLevel = (int) g_Filters[i].Level;
+               log->FilterLevel = g_Filters[i].Level;
+       else
+               log->FilterLevel = log->Level;
 
-       return iLevel;
+       return log->FilterLevel;
 }
 
 BOOL WLog_ParseName(wLog* log, LPCSTR name)
@@ -636,6 +640,7 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
        log->Parent = rootLogger;
        log->ChildrenCount = 0;
        log->ChildrenSize = 16;
+       log->FilterLevel = -1;
 
        if (!(log->Children = (wLog**) calloc(log->ChildrenSize, sizeof(wLog*))))
                goto out_fail;
index c3cc83e..596005d 100644 (file)
@@ -63,6 +63,7 @@ struct _wLogAppender
 struct _wLog
 {
        LPSTR Name;
+       LONG FilterLevel;
        DWORD Level;
 
        BOOL IsRoot;