mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
ITS#9715 allow setting both debug and loglevel in cn=monitor
This commit is contained in:
parent
d76b8cbbef
commit
9b03a1ec88
5 changed files with 84 additions and 31 deletions
|
|
@ -138,6 +138,8 @@ typedef struct monitor_info_t {
|
|||
AttributeDescription *mi_ad_monitorRuntimeConfig;
|
||||
AttributeDescription *mi_ad_monitorSuperiorDN;
|
||||
AttributeDescription *mi_ad_monitorConnectionOpsAsync;
|
||||
AttributeDescription *mi_ad_monitorLogLevel;
|
||||
AttributeDescription *mi_ad_monitorDebugLevel;
|
||||
|
||||
/*
|
||||
* Generic description attribute
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
|
|||
SLAPD_MONITOR_LOG_NAME,
|
||||
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
||||
{ BER_BVC( "This subsystem contains information about logging." ),
|
||||
BER_BVC( "Set the attribute \"managedInfo\" to the desired log levels." ),
|
||||
BER_BVC( "Set the \"monitorLogLevel\" or \"monitorDebugLevel\" attributes to the desired levels." ),
|
||||
BER_BVNULL },
|
||||
MONITOR_F_NONE,
|
||||
monitor_subsys_log_init,
|
||||
|
|
@ -1940,6 +1940,22 @@ monitor_back_initialize(
|
|||
"NO-USER-MODIFICATION "
|
||||
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
||||
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsAsync) },
|
||||
{ "( 1.3.6.1.4.1.4203.666.1.55.32 "
|
||||
"NAME 'monitorLogLevel' "
|
||||
"DESC 'current slapd log level' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SUBSTR caseIgnoreSubstringsMatch "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
|
||||
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
||||
offsetof(monitor_info_t, mi_ad_monitorLogLevel) },
|
||||
{ "( 1.3.6.1.4.1.4203.666.1.55.33 "
|
||||
"NAME 'monitorDebugLevel' "
|
||||
"DESC 'current slapd debug level' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SUBSTR caseIgnoreSubstringsMatch "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
|
||||
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
||||
offsetof(monitor_info_t, mi_ad_monitorDebugLevel) },
|
||||
{ NULL, 0, -1 }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,12 +59,10 @@ monitor_subsys_log_init(
|
|||
BackendDB *be,
|
||||
monitor_subsys_t *ms )
|
||||
{
|
||||
ms->mss_open = monitor_subsys_log_open;
|
||||
ldap_pvt_thread_mutex_init( &monitor_log_mutex );
|
||||
ms->mss_modify = monitor_subsys_log_modify;
|
||||
|
||||
ldap_pvt_thread_mutex_init( &monitor_log_mutex );
|
||||
|
||||
return( 0 );
|
||||
return monitor_subsys_log_open( be, ms );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -76,13 +74,10 @@ monitor_subsys_log_open(
|
|||
monitor_subsys_t *ms )
|
||||
{
|
||||
BerVarray bva = NULL;
|
||||
monitor_info_t *mi = ( monitor_info_t * )be->be_private;
|
||||
Entry *e = NULL;
|
||||
|
||||
if ( loglevel2bvarray( slap_syslog_get(), &bva ) == 0 && bva != NULL ) {
|
||||
monitor_info_t *mi;
|
||||
Entry *e;
|
||||
|
||||
mi = ( monitor_info_t * )be->be_private;
|
||||
|
||||
if ( loglevel2bvarray( slap_debug_get(), &bva ) == 0 && bva != NULL ) {
|
||||
if ( monitor_cache_get( mi, &ms->mss_ndn, &e ) ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"monitor_subsys_log_init: "
|
||||
|
|
@ -92,12 +87,28 @@ monitor_subsys_log_open(
|
|||
return( -1 );
|
||||
}
|
||||
|
||||
attr_merge_normalize( e, mi->mi_ad_managedInfo, bva, NULL );
|
||||
attr_merge_normalize( e, mi->mi_ad_monitorDebugLevel, bva, NULL );
|
||||
ber_bvarray_free( bva );
|
||||
|
||||
monitor_cache_release( mi, e );
|
||||
bva = NULL;
|
||||
}
|
||||
|
||||
if ( loglevel2bvarray( slap_syslog_get(), &bva ) == 0 && bva != NULL ) {
|
||||
if ( !e && monitor_cache_get( mi, &ms->mss_ndn, &e ) ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"monitor_subsys_log_init: "
|
||||
"unable to get entry \"%s\"\n",
|
||||
ms->mss_ndn.bv_val );
|
||||
ber_bvarray_free( bva );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
attr_merge_normalize( e, mi->mi_ad_monitorLogLevel, bva, NULL );
|
||||
ber_bvarray_free( bva );
|
||||
}
|
||||
|
||||
if ( e )
|
||||
monitor_cache_release( mi, e );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
|
@ -109,13 +120,16 @@ monitor_subsys_log_modify(
|
|||
{
|
||||
monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private;
|
||||
int rc = LDAP_OTHER;
|
||||
int newlevel = slap_syslog_get();
|
||||
int newdebug, newsyslog, *newptr;
|
||||
Attribute *save_attrs;
|
||||
Modifications *modlist = op->orm_modlist;
|
||||
Modifications *ml;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &monitor_log_mutex );
|
||||
|
||||
newdebug = slap_debug_get();
|
||||
newsyslog = slap_syslog_get();
|
||||
|
||||
save_attrs = e->e_attrs;
|
||||
e->e_attrs = attrs_dup( e->e_attrs );
|
||||
|
||||
|
|
@ -137,24 +151,30 @@ monitor_subsys_log_modify(
|
|||
continue;
|
||||
|
||||
/*
|
||||
* only the "managedInfo" attribute can be modified
|
||||
* only the monitorDebugLevel and monitorLogLevel attributes can be modified
|
||||
*/
|
||||
} else if ( mod->sm_desc != mi->mi_ad_managedInfo ) {
|
||||
rc = rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
|
||||
break;
|
||||
} else {
|
||||
if ( mod->sm_desc == mi->mi_ad_monitorDebugLevel ) {
|
||||
newptr = &newdebug;
|
||||
} else if ( mod->sm_desc == mi->mi_ad_monitorLogLevel ) {
|
||||
newptr = &newsyslog;
|
||||
} else {
|
||||
rc = rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( mod->sm_op ) {
|
||||
case LDAP_MOD_ADD:
|
||||
rc = add_values( op, e, mod, &newlevel );
|
||||
rc = add_values( op, e, mod, newptr );
|
||||
break;
|
||||
|
||||
case LDAP_MOD_DELETE:
|
||||
rc = delete_values( op, e, mod, &newlevel );
|
||||
rc = delete_values( op, e, mod, newptr );
|
||||
break;
|
||||
|
||||
case LDAP_MOD_REPLACE:
|
||||
rc = replace_values( op, e, mod, &newlevel );
|
||||
rc = replace_values( op, e, mod, newptr );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -191,15 +211,8 @@ monitor_subsys_log_modify(
|
|||
/*
|
||||
* Do we need to protect this with a mutex?
|
||||
*/
|
||||
slap_syslog_set( newlevel );
|
||||
|
||||
#if 0 /* debug rather than log */
|
||||
slap_debug = newlevel;
|
||||
lutil_set_debug_level( "slapd", slap_debug );
|
||||
ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
|
||||
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug);
|
||||
ldif_debug = slap_debug;
|
||||
#endif
|
||||
slap_syslog_set( newsyslog );
|
||||
slap_debug_set( newdebug );
|
||||
}
|
||||
|
||||
cleanup:;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "ldif.h"
|
||||
|
||||
#include "slap-config.h"
|
||||
#include "slap-cfglog.h"
|
||||
|
|
@ -449,6 +450,25 @@ slap_syslog_set( int l )
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
slap_debug_get()
|
||||
{
|
||||
return slap_debug_orig;
|
||||
}
|
||||
|
||||
void
|
||||
slap_debug_set( int l )
|
||||
{
|
||||
slap_debug_orig = l;
|
||||
if ( logfile_only )
|
||||
slap_debug = slap_debug_orig | active_syslog;
|
||||
else
|
||||
slap_debug = slap_debug_orig;
|
||||
ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
|
||||
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug);
|
||||
ldif_debug = slap_debug;
|
||||
}
|
||||
|
||||
int
|
||||
str2loglevel( const char *s, int *l )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1231,6 +1231,8 @@ LDAP_SLAPD_F (int) logfile_open LDAP_P(( const char *path ));
|
|||
LDAP_SLAPD_F (void) logfile_close LDAP_P(( void ));
|
||||
LDAP_SLAPD_F (void) slap_syslog_set LDAP_P(( int l ));
|
||||
LDAP_SLAPD_F (int) slap_syslog_get LDAP_P(( void ));
|
||||
LDAP_SLAPD_F (void) slap_debug_set LDAP_P(( int l ));
|
||||
LDAP_SLAPD_F (int) slap_debug_get LDAP_P(( void ));
|
||||
LDAP_SLAPD_F (const char *) logfile_name LDAP_P(( void ));
|
||||
LDAP_SLAPD_F (int)
|
||||
slap_parse_syslog_level LDAP_P(( const char *arg, int *levelp ));
|
||||
|
|
|
|||
Loading…
Reference in a new issue