/*
Authors:
Simo Sorce <ssorce@redhat.com>
Copyright (C) 2009 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SSSD_DEBUG_H__
#define __SSSD_DEBUG_H__
#include "config.h"
#else
#endif
extern const char *debug_prg_name;
extern int debug_level;
extern int debug_timestamps;
extern int debug_microseconds;
extern int debug_to_file;
extern int debug_to_stderr;
extern const char *debug_log_file;
void sss_vdebug_fn(const char *file,
long line,
const char *function,
int level,
int flags,
const char *format,
void sss_debug_fn(const char *file,
long line,
const char *function,
int level,
int debug_convert_old_level(int old_level);
int get_fd_from_debug_file(void);
#define SSSDBG_UNRESOLVED 0
#define SSSDBG_MICROSECONDS_DEFAULT 0
#define SSSD_DEBUG_OPTS \
_("Debug level"), NULL}, \
_("Send the debug output to files instead of stderr"), NULL }, \
_("Send the debug output to stderr directly."), NULL }, \
_("Add debug timestamps"), NULL}, \
_("Show timestamps with microseconds"), NULL},
/** \def DEBUG(level, format, ...)
\brief macro to generate debug messages
\param level the debug level, please use one of the SSSDBG_* macros
\param format the debug message format string, should result in a
newline-terminated message
\param ... the debug message format arguments
*/
int __debug_macro_level = level; \
if (DEBUG_IS_SET(__debug_macro_level)) { \
format, ##__VA_ARGS__); \
} \
} while (0)
/** \def DEBUG_IS_SET(level)
\brief checks whether level is set in debug_level
\param level the debug level, please use one of the SSSDBG*_ macros
*/
(debug_level == SSSDBG_UNRESOLVED && \
(level & (SSSDBG_FATAL_FAILURE | \
if (dbg_lvl != SSSDBG_INVALID) { \
} else { \
} \
\
} while (0)
/* CLI tools shall debug to stderr even when SSSD was compiled with journald
* support
*/
DEBUG_INIT(dbg_lvl); \
debug_to_stderr = 1; \
} while (0)
#endif /* __SSSD_DEBUG_H__ */