debug.c revision 71cd2f7ce705561d8d8f3cb7f385a57bedad1ef1
/*
Authors:
Simo Sorce <ssorce@redhat.com>
Stephen Gallagher <sgallagh@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/>.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
const char *debug_prg_name = "sssd";
int debug_level = 0;
int debug_timestamps = 1;
int debug_to_file = 0;
const char *debug_log_file = "sssd";
{
return errno;
}
debug_file = dummy;
return EOK;
}
{
}
{
int loglevel = -1;
int ret;
switch(level) {
case LDB_DEBUG_FATAL:
loglevel = 0;
break;
case LDB_DEBUG_ERROR:
loglevel = 1;
break;
case LDB_DEBUG_WARNING:
loglevel = 6;
break;
case LDB_DEBUG_TRACE:
loglevel = 9;
break;
}
if (ret < 0) {
/* ENOMEM */
return;
}
if (loglevel <= debug_level) {
if (debug_timestamps) {
char stamp[25];
debug_fn("(%s) [%s] [ldb] (%d): %s\n",
} else {
debug_fn("[%s] [ldb] (%d): %s\n",
}
}
}
{
char *logpath;
const char *log_file;
int ret;
} else {
}
if (ret == -1) {
return ENOMEM;
}
if (f == NULL) {
return EIO;
}
debug_file = f;
} else {
*filep = f;
}
return EOK;
}
int open_debug_file(void)
{
}
int rotate_debug_files(void)
{
int ret;
if (!debug_to_file) return EOK;
debug_file = NULL;
return open_debug_file();
}