Browse Source

core: helper function to get debug level for logging from config

Daniel-Constantin Mierla 6 years ago
parent
commit
89cc5ddeeb
2 changed files with 11 additions and 0 deletions
  1. 10 0
      src/core/dprint.c
  2. 1 0
      src/core/dprint.h

+ 10 - 0
src/core/dprint.c

@@ -169,6 +169,16 @@ int get_debug_level(char *mname, int mnlen) {
 				_local_debug_level : cfg_get(core, core_cfg, debug);
 }
 
+/**
+ * @brief return the log level - the local one if it set,
+ *   otherwise the global value
+ */
+int get_cfg_debug_level(void) {
+	/*important -- no LOGs inside, because it will loop */
+	return (_local_debug_level != UNSET_LOCAL_DEBUG_LEVEL) ?
+				_local_debug_level : cfg_get(core, core_cfg, debug);
+}
+
 /**
  * @brief return the log facility - the local one if it set,
  *   otherwise the global value

+ 1 - 0
src/core/dprint.h

@@ -141,6 +141,7 @@ struct log_level_info {
 
 /** @brief per process debug level handling */
 int get_debug_level(char *mname, int mnlen);
+int get_cfg_debug_level(void);
 int get_debug_facility(char *mname, int mnlen);
 void set_local_debug_level(int level);
 void set_local_debug_facility(int facility);