[Date Prev][Date Next] [Chronological] [Thread] [Top]


The NEW_LOGGING code definitely needs some rework.

I note that in slapd/config.c, the "logfile" directive is #if'd for
NEW_LOGGING, but it is actually applicable to either old or new logging.
Meanwhile, the "debug" directive is always compiled, but it is *only*
applicable to NEW_LOGGING.

Any debug/log mechanism that requires a function call before it can decide
whether or not to execute will impose a noticable performance loss.

I can see some advantage to having independent "channels" of log info, each
with their own priority levels. But I don't believe it's worthwhile to kill
performance to get there.

We can minimize the performance impact using those numeric subsystem IDs.
The individual subsystem levels should go in a global array for easy

extern int ldap_loglevels[LDAP_SUBSYS_NUM];

If we do the level check in the macro, we don't have to worry about those
arguments in the actual log function. So we can use

#define	LDAP_SUBSYS(x)	LDAP_SUBSYS_ ## x
#define	LDAP_LEVEL(x)	LDAP_LEVEL_ ## x

#define	LDAP_LOG(a, b, args) \
	if (ldap_loglevels[LDAP_SUBSYS(a)] >= LDAP_LEVEL(b))	lutil_log args

and then
	LDAP_LOG(OPERATION, INFO, ("%s: foobar %d at from %x", name, rc, addr));

will expand to
		lutil_log ("%s: foobar %d at from %x", name, rc, addr);

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support

-----Original Message-----
From: owner-openldap-devel@OpenLDAP.org
[mailto:owner-openldap-devel@OpenLDAP.org]On Behalf Of Julius Enarusai
Sent: Monday, April 22, 2002 8:23 AM
To: openldap-devel@OpenLDAP.org
Subject: Re: NEW_LOGGING

>While digging through looking for all the subsystem names for the "debug"
>directive it occurred to me that this NEW_LOGGING is a bit out of control.
>The only way to generate an exhaustive list of subsystem names is to grep
>the entire source tree.
>Also, this new logging mechanism will cause a noticable performance hit
>when it's compiled in, since it must do string-based searches on every
>invocation, just to decide if it needs to do any work or not. There are
>numeric subsystem IDs in ldap_log.h, which would be fine if they were
>being used, but nothing uses them.
>I guess I wasn't paying attention before, but shouldn't we be using these
>numeric subsystem IDs instead of arbitrary character strings?
>-- Howard Chu
>Chief Architect, Symas Corp.       Director, Highland Sun
>http://www.symas.com               http://highlandsun.com/hyc
>Symas: Premier OpenSource Development and Support


I noticed it also when I started adding LDAP_LOG messages to all the files.
Most of the LDAP_LOG messages right now are based on file and function name,
instead of subsystem. If the list of subsystem IDs in ldap_log.h has
everyone's blessings, I can make the changes since I'm currently working on