558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Simo Sorce <ssorce@redhat.com>
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Copyright (C) 2009 Red Hat
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik This program is free software; you can redistribute it and/or modify
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik it under the terms of the GNU General Public License as published by
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik the Free Software Foundation; either version 3 of the License, or
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik (at your option) any later version.
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik This program is distributed in the hope that it will be useful,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik but WITHOUT ANY WARRANTY; without even the implied warranty of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik GNU General Public License for more details.
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik You should have received a copy of the GNU General Public License
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik along with this program. If not, see <http://www.gnu.org/licenses/>.
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSS_ATTRIBUTE_PRINTF(a1, a2) __attribute__((format (printf, a1, a2)))
09e3f0af96cecb94be69084c025f0355b3111993Lukas Slebodnikextern const char *sss_logger_str[];
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikextern const char *debug_prg_name;
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikextern const char *debug_log_file;
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik const char *format, ...) SSS_ATTRIBUTE_PRINTF(5, 6);
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikerrno_t set_debug_file_from_fd(const int fd);
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_FATAL_FAILURE 0x0010 /* level 0 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_CRIT_FAILURE 0x0020 /* level 1 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_OP_FAILURE 0x0040 /* level 2 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_MINOR_FAILURE 0x0080 /* level 3 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_CONF_SETTINGS 0x0100 /* level 4 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_FUNC_DATA 0x0200 /* level 5 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_TRACE_FUNC 0x0400 /* level 6 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_TRACE_LIBS 0x1000 /* level 7 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_TRACE_INTERNAL 0x2000 /* level 8 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_TRACE_ALL 0x4000 /* level 9 */
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_IMPORTANT_INFO SSSDBG_OP_FAILURE
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define SSSDBG_MASK_ALL 0xFFF0 /* enable all debug levels */
09e3f0af96cecb94be69084c025f0355b3111993Lukas Slebodnik {"logger", '\0', POPT_ARG_STRING, &opt_logger, 0, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik {"debug-level", 'd', POPT_ARG_INT, &debug_level, 0, \
18a47bcc463c866de6b6b0327e6d85ceb1e0f7d6Lukas Slebodnik {"debug-to-files", 'f', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, &debug_to_file, 0, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _("Send the debug output to files instead of stderr"), NULL }, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik {"debug-to-stderr", 0, POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, &debug_to_stderr, 0, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _("Send the debug output to stderr directly."), NULL }, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik {"debug-timestamps", 0, POPT_ARG_INT, &debug_timestamps, 0, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik {"debug-microseconds", 0, POPT_ARG_INT, &debug_microseconds, 0, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _("Show timestamps with microseconds"), NULL},
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik/** \def DEBUG(level, format, ...)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik \brief macro to generate debug messages
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik \param level the debug level, please use one of the SSSDBG_* macros
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik \param format the debug message format string, should result in a
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik newline-terminated message
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik \param ... the debug message format arguments
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik sss_debug_fn(__FILE__, __LINE__, __FUNCTION__, \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik/** \def DEBUG_IS_SET(level)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik \brief checks whether level is set in debug_level
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik \param level the debug level, please use one of the SSSDBG*_ macros
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define DEBUG_IS_SET(level) (debug_level & (level) || \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik debug_level = debug_convert_old_level(dbg_lvl); \
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik/* CLI tools shall debug to stderr even when SSSD was compiled with journald
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik#endif /* __SSSD_DEBUG_H__ */