Skip to content
Snippets Groups Projects
Commit c5f83acf authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

cleanup

parent f01c60dd
No related branches found
No related tags found
No related merge requests found
......@@ -32,12 +32,6 @@
#include "lber.h"
#include "ldap_pvt.h"
struct DEBUGLEVEL
{
char *subsystem;
int level;
};
int ldap_loglevels[LDAP_SUBSYS_NUM];
static FILE *log_file = NULL;
......@@ -60,15 +54,15 @@ static int debug2syslog(int l) {
}
#endif
static char *lutil_levels[] = {
static char *debug_levels[] = {
"emergency", "alert", "critical",
"error", "warning", "notice",
"information", "entry", "args",
"results", "detail1", "detail2",
NULL };
static char *lutil_subsys[LDAP_SUBSYS_NUM] = {
"GLOBAL","OPERATION", "TRANSPORT",
static char *debug_subsys[LDAP_SUBSYS_NUM] = {
"GLOBAL", "OPERATION", "TRANSPORT",
"CONNECTION", "FILTER", "BER",
"CONFIG", "ACL", "CACHE", "INDEX",
"LDIF", "TOOLS", "SLAPD", "SLURPD",
......@@ -79,7 +73,7 @@ int lutil_mnem2subsys( const char *subsys )
{
int i;
for( i = 0; i < LDAP_SUBSYS_NUM; i++ ) {
if ( !strcasecmp( subsys, lutil_subsys[i] ) ) {
if ( !strcasecmp( subsys, debug_subsys[i] ) ) {
return i;
}
}
......@@ -89,9 +83,8 @@ int lutil_mnem2subsys( const char *subsys )
void lutil_set_all_backends( int level )
{
int i;
for( i = 0; i < LDAP_SUBSYS_NUM; i++ ) {
if ( !strncasecmp( "BACK_", lutil_subsys[i], sizeof("BACK_")-1 ) ) {
if ( !strncasecmp( "BACK_", debug_subsys[i], sizeof("BACK_")-1 ) ) {
ldap_loglevels[i] = level;
}
}
......@@ -100,8 +93,8 @@ void lutil_set_all_backends( int level )
int lutil_mnem2level( const char *level )
{
int i;
for( i = 0; lutil_levels[i] != NULL; i++ ) {
if ( !strcasecmp( level, lutil_levels[i] ) ) {
for( i = 0; debug_levels[i] != NULL; i++ ) {
if ( !strcasecmp( level, debug_levels[i] ) ) {
return i;
}
}
......@@ -227,7 +220,7 @@ void lutil_log( const int subsys, int level, const char *fmt, ... )
va_list vl;
va_start( vl, fmt );
ber_get_option( NULL, LBER_OPT_LOG_PRINT_FILE, &outfile );
lutil_log_int( outfile, lutil_subsys[subsys], level, fmt, vl );
lutil_log_int( outfile, debug_subsys[subsys], level, fmt, vl );
va_end( vl );
}
......@@ -267,9 +260,9 @@ void lutil_log_initialize(int argc, char **argv)
global_level = atoi( optarg );
ldap_loglevels[0] = global_level;
/*
* if a negative number was used, make the global level the
* maximum sane level.
*/
* if a negative number was used, make the global level the
* maximum sane level.
*/
if ( global_level < 0 ) {
global_level = 65535;
ldap_loglevels[0] = 65535;
......@@ -298,16 +291,14 @@ void (lutil_debug)( int debug, int level, const char *fmt, ... )
ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, log_file );
}
#endif
va_start( vl, fmt );
va_start( vl, fmt );
vsnprintf( buffer, sizeof(buffer), fmt, vl );
buffer[sizeof(buffer)-1] = '\0';
if( log_file != NULL ) {
fputs( buffer, log_file );
fflush( log_file );
}
fputs( buffer, stderr );
va_end( vl );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment