summaryrefslogtreecommitdiff
path: root/src/util/util.h
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2011-08-03 09:15:52 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-08-25 15:46:11 -0400
commit89caf5edcc99f5731e89bd51e6ffaad3ec11c304 (patch)
treed7b5638ccf515fac99454d18d7685d2329450e02 /src/util/util.h
parentfe60346714a73ac3987f786731389320633dd245 (diff)
downloadsssd-89caf5edcc99f5731e89bd51e6ffaad3ec11c304.tar.gz
sssd-89caf5edcc99f5731e89bd51e6ffaad3ec11c304.tar.bz2
sssd-89caf5edcc99f5731e89bd51e6ffaad3ec11c304.zip
New DEBUG facility - SSSDBG_UNRESOLVED changed from -1 to 0
Removed: SSS_UNRESOLVED_DEBUG_LEVEL (completely replaced with SSSDBG_UNRESOLVED) Added new macro: CONVERT_AND_SET_DEBUG_LEVEL(new_value) Changes unresolved debug level value (SSSDBG_UNRESOLVED) from -1 to 0 so DEBUG macro could be reduced by one condition. Anyway, it has a minor effect, every time you want to load debug_level from command line parameters, you have to use following pattern: /* Set debug level to invalid value so we can deside if -d 0 was used. */ debug_level = SSSDBG_INVALID; pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { ... } CONVERT_AND_SET_DEBUG_LEVEL(debug_level);
Diffstat (limited to 'src/util/util.h')
-rw-r--r--src/util/util.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/util/util.h b/src/util/util.h
index 22b0937d..c37cab8a 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -61,8 +61,6 @@ int debug_get_level(int old_level);
int debug_convert_old_level(int old_level);
errno_t set_debug_file_from_fd(const int fd);
-#define SSS_UNRESOLVED_DEBUG_LEVEL SSSDBG_UNRESOLVED
-
#define SSSDBG_FATAL_FAILURE 0x0010 /* level 0 */
#define SSSDBG_CRIT_FAILURE 0x0020 /* level 1 */
#define SSSDBG_OP_FAILURE 0x0040 /* level 2 */
@@ -74,7 +72,8 @@ errno_t set_debug_file_from_fd(const int fd);
#define SSSDBG_TRACE_INTERNAL 0x2000 /* level 8 */
#define SSSDBG_TRACE_ALL 0x4000 /* level 9 */
-#define SSSDBG_UNRESOLVED -1
+#define SSSDBG_INVALID -1
+#define SSSDBG_UNRESOLVED 0
#define SSSDBG_MASK_ALL 0xFFF0 /* enable all debug levels */
#define SSSDBG_DEFAULT SSSDBG_FATAL_FAILURE
@@ -153,7 +152,13 @@ errno_t set_debug_file_from_fd(const int fd);
\param level the debug level, please use one of the SSSDBG*_ macros
*/
-#define DEBUG_IS_SET(level) ((debug_level > 0) && (debug_level & (level)))
+#define DEBUG_IS_SET(level) (debug_level & (level))
+
+#define CONVERT_AND_SET_DEBUG_LEVEL(new_value) debug_level = ( \
+ ((new_value) != SSSDBG_INVALID) \
+ ? debug_convert_old_level(new_value) \
+ : SSSDBG_UNRESOLVED /* Debug level should be loaded from config file. */ \
+);
#define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__)
#define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__)