debug.c revision 99dd40a885ed3d42af4bbbde7ee2fc98830544d0
/*
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/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
const char *debug_prg_name = "sssd";
int debug_level = SSSDBG_UNRESOLVED;
int debug_to_file = 0;
const char *debug_log_file = "sssd";
{
errno = 0;
return ret;
}
debug_file = dummy;
return EOK;
}
int debug_convert_old_level(int old_level)
{
return old_level;
if( old_level == SSS_UNRESOLVED_DEBUG_LEVEL )
return SSSDBG_UNRESOLVED;
int new_level = SSSDBG_FATAL_FAILURE;
if (old_level == 0)
return new_level;
if (old_level >= 1)
if (old_level >= 2)
if (old_level >= 3)
if (old_level >= 4)
if (old_level >= 5)
if (old_level >= 6)
if (old_level >= 7)
if (old_level >= 8)
if (old_level >= 9)
return new_level;
}
{
}
int debug_get_level(int old_level)
{
return old_level;
if( old_level == SSS_UNRESOLVED_DEBUG_LEVEL )
return SSSDBG_UNRESOLVED;
return SSSDBG_FATAL_FAILURE;
int levels[] = {
SSSDBG_FATAL_FAILURE, /* 0 */
SSSDBG_TRACE_ALL /* 9 */
};
}
{
int loglevel = SSSDBG_UNRESOLVED;
int ret;
switch(level) {
case LDB_DEBUG_FATAL:
break;
case LDB_DEBUG_ERROR:
break;
case LDB_DEBUG_WARNING:
break;
case LDB_DEBUG_TRACE:
break;
}
if (ret < 0) {
/* ENOMEM */
return;
}
}
{
char *logpath;
const char *log_file;
int ret;
} else {
}
if (ret == -1) {
return ENOMEM;
}
errno = 0;
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;
do {
error = 0;
if (ret != 0) {
}
/* Check for EINTR, which means we should retry
* because the system call was interrupted by a
* signal
*/
if (error != 0) {
/* Even if we were unable to close the debug log, we need to make
* sure that we open up a new one. Log rotation will remove the
* current file, so all debug messages will be disappearing.
*
* We should write an error to the syslog warning of the resource
* leak and then proceed with opening the new file.
*/
"Be aware that this is a resource leak\n");
}
debug_file = NULL;
return open_debug_file();
}