]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Log Facility: Infrastructure changes for module level filtering
authorJohn Wolfe <jwolfe@vmware.com>
Fri, 11 Sep 2020 19:11:04 +0000 (12:11 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Fri, 11 Sep 2020 19:11:04 +0000 (12:11 -0700)
Additional changes to log.h and loglevel_userVars.h

open-vm-tools/lib/include/log.h
open-vm-tools/lib/include/loglevel_userVars.h

index 1e3ca5b79bc8696a80f1555e748ce2bea252f4b0..7381ba88357df894ba88db6230caad24b4bc0101 100644 (file)
@@ -54,6 +54,7 @@ extern "C" {
  *      Level              Comments
  *-------------------------------------------------
  */
+
 typedef enum {
    VMW_LOG_AUDIT    = 0,   // ALWAYS LOGGED; NO STDERR
    VMW_LOG_PANIC    = 1,   // Quietest level
@@ -83,13 +84,44 @@ typedef enum {
 #endif
 
 /*
- * The "routing" parameter may contain other information. Be sure to
- * use the VMW_LOG_LEVEL_MASK when checking for a level!
+ * The "routing" parameter contains the level in the low order bits; the
+ * higher order bits specify the module where the log call came from.
  */
 
 #define VMW_LOG_LEVEL_BITS 5  // Log level bits (32 levels max)
 #define VMW_LOG_LEVEL_MASK ((int)(1 << VMW_LOG_LEVEL_BITS) - 1)
 
+#define VMW_LOG_LEVEL(routing)  ((routing) & VMW_LOG_LEVEL_MASK)
+#define VMW_LOG_MODULE(routing) (((routing) >> VMW_LOG_LEVEL_BITS))
+
+/*
+ * To use the Log Facility module specific filters:
+ *
+ *  1) Use LogV or Log_Level and use the LOG_ROUTING_BITS macro.
+ *
+ *  2) Have LOGLEVEL_MODULE defined before the include of "log.h".
+ *
+ *     For many files, this involves moving the include "log.h" after
+ *     the include of "loglevel_user.h".
+ */
+
+#if defined(LOGLEVEL_MODULE)
+   #include "loglevel_userVars.h"
+   #include "vm_basic_defs.h"
+
+   #define LOGFACILITY_MODULEVAR(mod) XCONC(_logFacilityModule_, mod)
+
+   enum LogFacilityModuleValue {
+      LOGLEVEL_USER(LOGFACILITY_MODULEVAR)
+   };
+
+   /* Module bits of zero (0) indicate no module has been specified */
+   #define LOG_ROUTING_BITS(level) \
+      (((LOGFACILITY_MODULEVAR(LOGLEVEL_MODULE) + 1) << VMW_LOG_LEVEL_BITS) | level)
+#else
+   #define LOG_ROUTING_BITS(level) (level)
+#endif
+
 void LogV(uint32 routing,
           const char *fmt,
           va_list args);
@@ -98,12 +130,9 @@ void Log_Level(uint32 routing,
                const char *fmt,
                ...) PRINTF_DECL(2, 3);
 
-
 /*
- * Handy wrapper functions.
- *
- * Log     -> VMW_LOG_INFO
- * Warning -> VMW_LOG_WARNING
+ * Log     = Log_Info
+ * Warning = Log_Warning
  */
 
 static INLINE void PRINTF_DECL(1, 2)
index 20ecd282f99124a6bd6e2c7914fe27dadadcb4bb..f94faa0da15d988b96c02c3218c18ae86123eefb 100644 (file)
@@ -20,6 +20,7 @@
 #define _LOGLEVEL_USER_VARS_H_
 
 #define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_VMCORE
 #define INCLUDE_ALLOW_USERLEVEL
 #include "includeCheck.h"