debug_priv.h
Go to the documentation of this file.
/*
* Copyright 2011 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors:
* Daniel Kopecek <dkopecek@redhat.com>
* Peter Vrabec <pvrabec@redhat.com>
*/
#pragma once
#ifndef OSCAP_DEBUG_PRIV_H_
#define OSCAP_DEBUG_PRIV_H_
#include "util.h"
#ifndef OSCAP_DEBUG_FILE
# define OSCAP_DEBUG_FILE "oscap_debug.log"
#endif
#ifndef OSCAP_DEBUG_FILE_ENV
# define OSCAP_DEBUG_FILE_ENV "OSCAP_DEBUG_FILE"
#endif
#ifndef OSCAP_DEBUG_LEVEL_ENV
# define OSCAP_DEBUG_LEVEL_ENV "OSCAP_DEBUG_LEVEL"
#endif
#ifndef OSCAP_DEBUG_PATHSTRIP_ENV
# define OSCAP_DEBUG_PATHSTRIP_ENV "OSCAP_DEBUG_PSTRIP"
#endif
#define OSCAP_DEBUGOBJ_SEXP 1
#include <assert.h>
#ifndef _A
#define _A(x) assert(x)
#endif
#if defined(NDEBUG)
# define oscap_dlprintf(...) while(0)
# define debug(l) if (0)
# define dO(type, obj) while(0)
#else
# include <stdlib.h>
# include <stddef.h>
# include <stdarg.h>
enum {
DBG_E = 1,
DBG_W,
DBG_I
};
# define __dlprintf_wrapper(l, ...) __oscap_dlprintf (l, __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
extern int __debuglog_level;
# define debug(l) if ((__debuglog_level = (__debuglog_level == -1 ? atoi (getenv (OSCAP_DEBUG_LEVEL_ENV) == NULL ? "0" : getenv (OSCAP_DEBUG_LEVEL_ENV)) : __debuglog_level)) && __debuglog_level >= (l))
void __oscap_dlprintf(int level, const char *file, const char *fn, size_t line, const char *fmt, ...);
# define oscap_dlprintf(l, ...) __dlprintf_wrapper (l, __VA_ARGS__)
void __oscap_debuglog_object (const char *file, const char *fn, size_t line, int objtype, void *obj);
# define dO(type, obj) __oscap_debuglog_object(__FILE__, __PRETTY_FUNCTION__, __LINE__, type, obj)
#endif /* NDEBUG */
#define dI(...) oscap_dlprintf(DBG_I, __VA_ARGS__)
#define dW(...) oscap_dlprintf(DBG_W, __VA_ARGS__)
#define dE(...) oscap_dlprintf(DBG_E, __VA_ARGS__)
#endif