Use PKIXERRORNUM, rather thana String, to indicate module to be logged (in NSS_LIBPKIX_BRANCH
authorrichard.freedman%sun.com
Thu, 18 May 2006 19:10:14 +0000
branchNSS_LIBPKIX_BRANCH
changeset 7089 cc104b4d20a441f148145314d5bc2d2c9fbe9b75
parent 7088 91d116cf646c57a6bc280c42fab133d39685e5ca
child 7092 5dcff83f7626fe892409825ee8d0a2575409e968
push idunknown
push userunknown
push dateunknown
Use PKIXERRORNUM, rather thana String, to indicate module to be logged (in Logger calls). Thus typos will be caught at compile time rather than during execution.
security/nss/cmd/libpkix/pkix/top/validatechain_NB/test_validatechain_NB.c
security/nss/cmd/libpkix/pkix/util/logger/test_logger.c
security/nss/lib/libpkix/include/pkix_util.h
security/nss/lib/libpkix/include/pkixt.h
security/nss/lib/libpkix/pkix/util/pkix_logger.c
security/nss/lib/libpkix/pkix/util/pkix_logger.h
--- a/security/nss/cmd/libpkix/pkix/top/validatechain_NB/test_validatechain_NB.c
+++ b/security/nss/cmd/libpkix/pkix/top/validatechain_NB/test_validatechain_NB.c
@@ -140,55 +140,53 @@ cleanup:
 char *levels[] = {
         "None", "Fatal Error", "Error", "Warning", "Debug", "Trace"
 };
 
 PKIX_Error *loggerCallback(
         PKIX_Logger *logger,
         PKIX_PL_String *message,
         PKIX_UInt32 logLevel,
-        PKIX_PL_String *logComponent,
+        PKIX_ERRORNUM logComponent,
         void *plContext)
 {
 #define resultSize 150
-        char *comp = NULL;
         char *msg = NULL;
         char result[resultSize];
 
         PKIX_TEST_STD_VARS();
 
         msg = PKIX_String2ASCII(message, plContext);
-        comp = PKIX_String2ASCII(logComponent, plContext);
         PR_snprintf(result, resultSize,
-            "Logging %s (%s): %s", levels[logLevel], comp, msg);
+            "Logging %s (%s): %s",
+	    levels[logLevel],
+	    PKIX_ERRORNAMES[logComponent],
+	    msg);
         subTest(result);
 
 cleanup:
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(msg, plContext));
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(comp, plContext));
         PKIX_TEST_RETURN();
 }
 
 void testLogErrors(
-	char *module,
+	PKIX_ERRORNUM module,
 	PKIX_UInt32 loggingLevel,
         PKIX_List *loggers,
 	void *plContext)
 {
         PKIX_Logger *logger = NULL;
         PKIX_PL_String *component = NULL;
 
         PKIX_TEST_STD_VARS();
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_Create
                 (loggerCallback, NULL, &logger, plContext));
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_String_Create
-                (PKIX_ESCASCII, module, 0, &component, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetLoggingComponent
-                (logger, component, plContext));
+                (logger, module, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetMaxLoggingLevel
                 (logger, loggingLevel, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_AppendItem
                 (loggers, (PKIX_PL_Object *) logger, plContext));
 
 cleanup:
         PKIX_TEST_DECREF_AC(logger);
         PKIX_TEST_DECREF_AC(component);
@@ -317,20 +315,24 @@ int main(int argc, char *argv[]){
 
         logging = PR_GetEnv("LOGGING");
         /* Is LOGGING set in the environment? */
         if ((logging != NULL) && (*logging != '\0')) {
 
                 PKIX_TEST_EXPECT_NO_ERROR
                         (PKIX_List_Create(&loggers, plContext));
 
-		testLogErrors("VALIDATE", 2, loggers, plContext);
-		testLogErrors("CERTCHAINCHECKER", 2, loggers, plContext);
-		testLogErrors("LDAPDEFAULTCLIENT", 2, loggers, plContext);
-		testLogErrors("CERTSTORE", 2, loggers, plContext);
+		testLogErrors
+			(PKIX_VALIDATE_ERROR, 2, loggers, plContext);
+		testLogErrors
+			(PKIX_CERTCHAINCHECKER_ERROR, 2, loggers, plContext);
+		testLogErrors
+			(PKIX_LDAPDEFAULTCLIENT_ERROR, 2, loggers, plContext);
+		testLogErrors
+			(PKIX_CERTSTORE_ERROR, 2, loggers, plContext);
 
                 PKIX_TEST_EXPECT_NO_ERROR(PKIX_SetLoggers(loggers, plContext));
 
         }
 
         pkixTestErrorResult = PKIX_ValidateChain_NB
                 (valParams,
                 &certIndex,
--- a/security/nss/cmd/libpkix/pkix/util/logger/test_logger.c
+++ b/security/nss/cmd/libpkix/pkix/util/logger/test_logger.c
@@ -54,66 +54,62 @@ char *levels[] = {
         "Debug",
         "Trace"
 };
 
 PKIX_Error *testLoggerCallback(
         PKIX_Logger *logger,
         PKIX_PL_String *message,
         PKIX_UInt32 logLevel,
-        PKIX_PL_String *logComponent,
+        PKIX_ERRORNUM logComponent,
         void *plContext)
 {
         char *comp = NULL;
         char *msg = NULL;
         char result[100];
         static int callCount = 0;
 
         PKIX_TEST_STD_VARS();
 
         msg = PKIX_String2ASCII(message, plContext);
-        comp = PKIX_String2ASCII(logComponent, plContext);
         PR_snprintf(result, 100, "Logging %s (%s): %s",
-                levels[logLevel], comp, msg);
+                levels[logLevel], PKIX_ERRORNAMES[logComponent], msg);
         subTest(result);
 
         callCount++;
         if (callCount > 1) {
                 testError("Incorrect number of Logger Callback <expect 1>");
         }
 
 cleanup:
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(msg, plContext));
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(comp, plContext));
         PKIX_TEST_RETURN();
 }
 
 PKIX_Error *testLoggerCallback2(
         PKIX_Logger *logger,
         PKIX_PL_String *message,
         PKIX_UInt32 logLevel,
-        PKIX_PL_String *logComponent,
+        PKIX_ERRORNUM logComponent,
         void *plContext)
 {
         char *comp = NULL;
         char *msg = NULL;
         char result[100];
 
         PKIX_TEST_STD_VARS();
 
         msg = PKIX_String2ASCII(message, plContext);
-        comp = PKIX_String2ASCII(logComponent, plContext);
         PR_snprintf(result, 100, "Logging %s (%s): %s",
-                levels[logLevel], comp, msg);
+                levels[logLevel], PKIX_ERRORNAMES[logComponent], msg);
         subTest(result);
 
 cleanup:
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(msg, plContext));
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(comp, plContext));
         PKIX_TEST_RETURN();
 }
 
 void
 createLogger(PKIX_Logger **logger,
         PKIX_PL_Object *context,
         PKIX_Logger_LogCallback cb)
 {
@@ -156,51 +152,43 @@ cleanup:
 
         PKIX_TEST_DECREF_AC(context);
         PKIX_TEST_RETURN();
 }
 
 void
 testComponent(PKIX_Logger *logger)
 {
-        PKIX_PL_String *compName = NULL;
-        PKIX_PL_String *compNameReturn = NULL;
+        PKIX_ERRORNUM compName = (PKIX_ERRORNUM)NULL;
+        PKIX_ERRORNUM compNameReturn = (PKIX_ERRORNUM)NULL;
         PKIX_Boolean cmpResult = PKIX_FALSE;
         PKIX_TEST_STD_VARS();
 
         subTest("PKIX_Logger_GetLoggingComponent");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetLoggingComponent
                 (logger, &compName, plContext));
 
-        if (compName != NULL) {
+        if (compName != (PKIX_ERRORNUM)NULL) {
                 testError("Incorrect Logger Component returned. expect <NULL>");
         }
 
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_String_Create
-                (PKIX_ESCASCII, "LIST", 0, &compName, plContext));
-
-
         subTest("PKIX_Logger_SetLoggingComponent");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetLoggingComponent
-                (logger, compName, plContext));
+                (logger, PKIX_LIST_ERROR, plContext));
 
         subTest("PKIX_Logger_GetLoggingComponent");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetLoggingComponent
                 (logger, &compNameReturn, plContext));
 
-        testEqualsHelper
-                ((PKIX_PL_Object *) compName,
-                (PKIX_PL_Object *) compNameReturn,
-                PKIX_TRUE,
-                plContext);
+        if (compNameReturn != PKIX_LIST_ERROR) {
+                testError("Incorrect Logger Component returned.");
+        }
 
 cleanup:
 
-        PKIX_TEST_DECREF_AC(compName);
-        PKIX_TEST_DECREF_AC(compNameReturn);
         PKIX_TEST_RETURN();
 }
 
 void
 testMaxLoggingLevel(PKIX_Logger *logger)
 {
         PKIX_UInt32 level = 0;
         PKIX_TEST_STD_VARS();
@@ -230,24 +218,23 @@ cleanup:
         PKIX_TEST_RETURN();
 }
 
 void
 testLogger(PKIX_Logger *logger, PKIX_Logger *logger2)
 {
         PKIX_List *loggerList = NULL;
         PKIX_List *checkList = NULL;
-        PKIX_PL_String *compName = NULL;
         PKIX_UInt32 length;
         PKIX_Boolean cmpResult = PKIX_FALSE;
         char *expectedAscii = "[\n"
                 "\tLogger: \n"
                 "\tContext:          (null)\n"
                 "\tMaximum Level:    3\n"
-                "\tComponment Name:  List\n"
+                "\tComponent Name:   LIST\n"
                 "]\n";
 
 
         PKIX_TEST_STD_VARS();
 
         subTest("PKIX_GetLoggers");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_GetLoggers(&loggerList, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength
@@ -259,22 +246,19 @@ testLogger(PKIX_Logger *logger, PKIX_Log
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&loggerList, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_AppendItem
                 (loggerList, (PKIX_PL_Object *) logger, plContext));
 
         subTest("PKIX_SetLoggers");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_SetLoggers(loggerList, plContext));
 
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_String_Create
-                (PKIX_ESCASCII, "OBJECT", 0, &compName, plContext));
-
         subTest("PKIX_Logger_SetLoggingComponent");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetLoggingComponent
-                (logger2, compName, plContext));
+                (logger2, PKIX_MUTEX_ERROR, plContext));
 
         subTest("PKIX_Logger_SetMaxLoggingLevel");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetMaxLoggingLevel
                 (logger2, 5, plContext));
 
         subTest("PKIX_AddLogger");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_AddLogger(logger2, plContext));
 
@@ -314,17 +298,16 @@ testLogger(PKIX_Logger *logger, PKIX_Log
         subTest("Expect to have ***Fatal Error (List): Null argument*** once");
         PKIX_TEST_EXPECT_ERROR(PKIX_List_AppendItem
                 (NULL, (PKIX_PL_Object *) NULL, plContext));
 
 cleanup:
 
         PKIX_TEST_DECREF_AC(loggerList);
         PKIX_TEST_DECREF_AC(checkList);
-        PKIX_TEST_DECREF_AC(compName);
         PKIX_TEST_RETURN();
 }
 void
 testDestroy(PKIX_Logger *logger)
 {
         PKIX_TEST_STD_VARS();
 
         PKIX_TEST_DECREF_BC(logger);
--- a/security/nss/lib/libpkix/include/pkix_util.h
+++ b/security/nss/lib/libpkix/include/pkix_util.h
@@ -122,17 +122,18 @@ extern "C" {
  *  "logger"
  *      Address of logger whose LogCallback is to be used. Must be non-NULL.
  *  "message"
  *      Address of String that is to be logged used "logger". Must be non-NULL.
  *  "logLevel"
  *      Integer value representing the log level for this entry. The higher the
  *      level, the more detail. Must be non-NULL.
  *  "logComponent"
- *      Address of String representing the log component for this entry.
+ *      PKIXERRORNUM value (defined in pkixt.h) designating the log component
+ *      for this entry.
  *  "plContext"
  *      Platform-specific context pointer.
  * THREAD SAFETY:
  *  Thread Safe
  *
  *  Multiple threads must be able to safely call this function without
  *  worrying about conflicts, even if they're operating on the same objects.
  * RETURNS:
@@ -140,17 +141,17 @@ extern "C" {
  *  Returns a Logger Error if the function fails in a non-fatal way.
  *  Returns a Fatal Error if the function fails in an unrecoverable way.
  */
 typedef PKIX_Error *
 (*PKIX_Logger_LogCallback)(
         PKIX_Logger *logger,
         PKIX_PL_String *message,
         PKIX_UInt32 logLevel,
-        PKIX_PL_String *logComponent,
+        PKIX_ERRORNUM logComponent,
         void *plContext);
 
 /*
  * FUNCTION: PKIX_Logger_Create
  * DESCRIPTION:
  *
  *  Creates a new Logger using the Object pointed to by "loggerContext"
  *  (if any) and stores it at "pLogger". The new Logger uses the LogCallback
@@ -305,65 +306,63 @@ PKIX_Logger_SetMaxLoggingLevel(
  *  entries whose log component matches the specified logging component will
  *  be logged.
  *
  * PARAMETERS:
  *  "logger"
  *      Address of Logger whose logging component is to be stored.
  *      Must be non-NULL.
  *  "pComponent"
- *      Address where object pointer will be stored. Must be non-NULL.
+ *      Address where PKIXERRORNUM will be stored. Must be non-NULL.
  *  "plContext"
  *      Platform-specific context pointer.
  * THREAD SAFETY:
  *  Conditionally Thread Safe
  *      (see Thread Safety Definitions in Programmer's Guide)
  * RETURNS:
  *  Returns NULL if the function succeeds.
  *  Returns a Logger Error if the function fails in a non-fatal way.
  *  Returns a Fatal Error if the function fails in an unrecoverable way.
  */
 PKIX_Error *
 PKIX_Logger_GetLoggingComponent(
         PKIX_Logger *logger,
-        PKIX_PL_String **pComponent,
+        PKIX_ERRORNUM *pComponent,
         void *plContext);
 
 /*
  * FUNCTION: PKIX_Logger_SetLoggingComponent
  * DESCRIPTION:
  *
  *  Sets the logging component of the Logger pointed to by "logger" with the
- *  String pointed to by "component". A NULL component matches all components.
- *  To match a small set of components, create a Logger for each.
+ *  PKIXERRORNUM pointed to by "component". To match a small set of components,
+ *  create a Logger for each.
  *
  * PARAMETERS:
  *  "logger"
  *      Address of Logger whose logging component is to be set.
  *      Must be non-NULL.
  *  "component"
- *      Address of String representing logging component to be set.
- *      If NULL, applies to all components.
+ *      PKIXERRORNUM value representing logging component to be set.
  *  "plContext"
  *      Platform-specific context pointer.
  * THREAD SAFETY:
  *  Not Thread Safe - assumes exclusive access to "logger"
  *  (see Thread Safety Definitions in Programmer's Guide)
  * RETURNS:
  *  Returns NULL if the function succeeds.
  *  Returns a Logger Error if the function fails in a non-fatal way.
  *  Returns a Fatal Error if the function fails in an unrecoverable way.
  */
 PKIX_Error *
 PKIX_Logger_SetLoggingComponent(
         PKIX_Logger *logger,
-        PKIX_PL_String *component,
+        PKIX_ERRORNUM component,
         void *plContext);
 
-
 /*
  * FUNCTION: PKIX_GetLoggers
  * DESCRIPTION:
  *
  *  Retrieves a pointer to the List of Loggers (if any) being used for logging
  *  by libpkix and stores it at "pLoggers". If no loggers are being used, this
  *  function stores an empty List at "pLoggers".
  *
--- a/security/nss/lib/libpkix/include/pkixt.h
+++ b/security/nss/lib/libpkix/include/pkixt.h
@@ -341,20 +341,20 @@ typedef int PKIX_Boolean;
    ERRMACRO(AIAMGR), \
    ERRMACRO(OCSPCHECKER), \
    ERRMACRO(OCSPREQUEST), \
    ERRMACRO(OCSPRESPONSE), \
    ERRMACRO(HTTPDEFAULTCLIENT)
 
 #define ERRMACRO(type) PKIX_ ## type ## _ERROR
 
-enum {
+typedef enum {
    PKIX_ERRORS,
    PKIX_NUMERRORS   /* This gets PKIX_NUMERRORS defined as the total number */
-};
+} PKIX_ERRORNUM;
 
 /* String Formats
  *
  * These formats specify supported encoding formats for Strings.
  */
 
 #define PKIX_ESCASCII           0
 #define PKIX_UTF8               1
--- a/security/nss/lib/libpkix/pkix/util/pkix_logger.c
+++ b/security/nss/lib/libpkix/pkix/util/pkix_logger.c
@@ -114,28 +114,27 @@ PKIX_PL_MonitorLock *pkixLoggerLock = NU
  *  Returns NULL if the function succeeds
  *  Returns a Fatal Error if the function fails in an unrecoverable way
  */
 PKIX_Error *
 pkix_Logger_Check(
         PKIX_List *pkixLoggersList,
         char *message,
         char *message2,
-        PKIX_UInt32 logComponent,
+        PKIX_ERRORNUM logComponent,
         PKIX_UInt32 currentLevel,
         void *plContext)
 {
         PKIX_Logger *logger = NULL;
         PKIX_List *savedPkixLoggersErrors = NULL;
         PKIX_List *savedPkixLoggersDebugTrace = NULL;
         PKIX_PL_String *formatString = NULL;
         PKIX_PL_String *messageString = NULL;
         PKIX_PL_String *message2String = NULL;
         PKIX_PL_String *msgString = NULL;
-        PKIX_PL_String *logComponentString = NULL;
         PKIX_Error *error = NULL;
         PKIX_Boolean needLogging = PKIX_FALSE;
         PKIX_UInt32 i, length;
 
         /*
          * We cannot use any the PKIX_ macros here, since this function is
          * called from some of these macros. It can create infinite recursion.
          */
@@ -189,32 +188,16 @@ pkix_Logger_Check(
         error = PKIX_PL_Sprintf
                     (&msgString,
                     plContext,
                     formatString,
                     messageString,
                     message2String);
         if (error) { goto cleanup; }
 
-        /*
-         * Convert component to String : see pkixt.h for reason that we have to
-         * use PKIX_NUMERRORS.
-         */
-        if (logComponent >= PKIX_NUMERRORS) {
-                goto cleanup;
-        }
-
-        error = PKIX_PL_String_Create
-                    (PKIX_ESCASCII,
-                    (void *)PKIX_ERRORNAMES[logComponent],
-                    0,
-                    &logComponentString,
-                    plContext);
-        if (error) { goto cleanup; }
-
         /* Go through the Logger list */
 
         error = PKIX_List_GetLength(pkixLoggersList, &length, plContext);
         if (error) { goto cleanup; }
 
         for (i = 0; i < length; i++) {
 
                 error = PKIX_List_GetItem
@@ -222,50 +205,48 @@ pkix_Logger_Check(
                     i,
                     (PKIX_PL_Object **) &logger,
                     plContext);
                 if (error) { goto cleanup; }
 
                 /* Intended logging level less or equal than the max */
                 needLogging = (currentLevel <= logger->maxLevel);
 
-                if (needLogging && logger->callback) {
+                if (needLogging && (logger->callback)) {
 
                     /*
                      * We separate Logger into two lists based on log level
                      * but log level is not modified. We need to check here to
                      * avoid logging the higher log level (lower value) twice.
                      */
                     if (pkixLoggersList == pkixLoggersErrors) {
                             needLogging = needLogging && 
                                 (currentLevel <= PKIX_LOGGER_LEVEL_WARNING);
                     } else if (pkixLoggersList == pkixLoggersDebugTrace) {
-                            needLogging = needLogging &&
+                            needLogging = needLogging && 
                                 (currentLevel > PKIX_LOGGER_LEVEL_WARNING);
                     }
                 
-                    if (needLogging && logger->logComponent) {
-                        error = PKIX_PL_Object_Equals(
-                            (PKIX_PL_Object *) logComponentString,
-                            (PKIX_PL_Object *) logger->logComponent,
-                            &needLogging,
-                            plContext);
-                        if (error) { goto cleanup; }
+                    if (needLogging) {
+                        if (logComponent == logger->logComponent) {
+                            needLogging = PKIX_TRUE;
+                        } else {
+                            needLogging = PKIX_FALSE;
+                        }
                     }
 
                     if (needLogging) {
                         error = logger->callback
                                 (logger,
                                 msgString,
                                 currentLevel,
-                                logComponentString,
+                                logComponent,
                                 plContext);
                         if (error) { goto cleanup; }
                     }
-
                 }
 
                 error = PKIX_PL_Object_DecRef
                         ((PKIX_PL_Object *)logger, plContext);
                 logger = NULL;
                 if (error) { goto cleanup; }
 
         }
@@ -287,21 +268,16 @@ cleanup:
                         ((PKIX_PL_Object *)message2String, plContext);
         }
 
         if (msgString) {
                 error = PKIX_PL_Object_DecRef
                         ((PKIX_PL_Object *)msgString, plContext);
         }
 
-        if (logComponentString) {
-                error = PKIX_PL_Object_DecRef
-                        ((PKIX_PL_Object *)logComponentString, plContext);
-        }
-
         if (logger) {
                 error = PKIX_PL_Object_DecRef
                         ((PKIX_PL_Object *)logger, plContext);
         }
 
         if (pkixLoggersErrors == NULL && savedPkixLoggersErrors != NULL) {
                 pkixLoggersErrors = savedPkixLoggersErrors;
         } 
@@ -336,17 +312,17 @@ pkix_Logger_Destroy(
                     "Object is not a Logger");
 
         logger = (PKIX_Logger *)object;
 
         /* We have a valid logger. DecRef its item and recurse on next */
 
         logger->callback = NULL;
         PKIX_DECREF(logger->context);
-        PKIX_DECREF(logger->logComponent);
+        logger->logComponent = (PKIX_ERRORNUM)NULL;
 
 cleanup:
 
         PKIX_RETURN(LOGGER);
 }
 
 /*
  * FUNCTION: pkix_Logger_ToString
@@ -357,53 +333,62 @@ pkix_Logger_ToString(
         PKIX_PL_Object *object,
         PKIX_PL_String **pString,
         void *plContext)
 {
         PKIX_Logger *logger = NULL;
         char *asciiFormat = NULL;
         PKIX_PL_String *formatString = NULL;
         PKIX_PL_String *contextString = NULL;
+        PKIX_PL_String *componentString = NULL;
         PKIX_PL_String *loggerString = NULL;
 
         PKIX_ENTER(LOGGER, "pkix_Logger_ToString_Helper");
         PKIX_NULLCHECK_TWO(object, pString);
 
         /* Check that this object is a logger */
         PKIX_CHECK(pkix_CheckType(object, PKIX_LOGGER_TYPE, plContext),
                     "Object is not a Logger");
 
         logger = (PKIX_Logger *)object;
 
         asciiFormat =
                 "[\n"
                 "\tLogger: \n"
                 "\tContext:          %s\n"
                 "\tMaximum Level:    %d\n"
-                "\tComponment Name:  %s\n"
+                "\tComponent Name:   %s\n"
                 "]\n";
 
         PKIX_CHECK(PKIX_PL_String_Create
                     (PKIX_ESCASCII,
                     asciiFormat,
                     0,
                     &formatString,
                     plContext),
                     "PKIX_PL_String_Create failed");
 
         PKIX_TOSTRING(logger->context, &contextString, plContext,
                 "PKIX_PL_Object_ToString failed");
 
+        PKIX_CHECK(PKIX_PL_String_Create
+                (PKIX_ESCASCII,
+                (void *)PKIX_ERRORNAMES[logger->logComponent],
+                0,
+                &componentString,
+                plContext),
+                "PKIX_PL_String_Create failed");
+
         PKIX_CHECK(PKIX_PL_Sprintf
                 (&loggerString,
                 plContext,
                 formatString,
                 contextString,
                 logger->maxLevel,
-                logger->logComponent),
+                componentString),
                 "PKIX_PL_Sprintf failed");
 
         *pString = loggerString;
 
 cleanup:
 
         PKIX_DECREF(formatString);
         PKIX_DECREF(contextString);
@@ -456,38 +441,35 @@ pkix_Logger_Equals(
         secondLogger = (PKIX_Logger *)second;
 
         cmpResult = PKIX_FALSE;
 
         if (firstLogger->callback != secondLogger->callback) {
                 goto cleanup;
         }
 
+        if (firstLogger->logComponent != secondLogger->logComponent) {
+                goto cleanup;
+        }
+
         PKIX_EQUALS  
                 (firstLogger->context,
                 secondLogger->context,
                 &cmpResult,
                 plContext,
                 "PKIX_PL_Object_Equals failed");
 
         if (cmpResult == PKIX_FALSE) {
                 goto cleanup;
         }
 
         if (firstLogger->maxLevel != secondLogger->maxLevel) {
                 goto cleanup;
         }
 
-        PKIX_EQUALS
-                ((PKIX_PL_Object *)firstLogger->logComponent,
-                (PKIX_PL_Object *)secondLogger->logComponent,
-                &cmpResult,
-                plContext,
-                "PKIX_PL_Object_Equals failed");
-
         *pResult = cmpResult;
 
 cleanup:
 
         PKIX_RETURN(LOGGER);
 }
 
 /*
@@ -510,23 +492,18 @@ pkix_Logger_Hashcode(
         PKIX_CHECK(pkix_CheckType(object, PKIX_LOGGER_TYPE, plContext),
                     "Object is not a logger");
 
         logger = (PKIX_Logger *)object;
 
         PKIX_HASHCODE(logger->context, &tempHash, plContext,
                 "PKIX_PL_Object_Hashcode failed");
 
-        hash = (PKIX_UInt32) logger->callback + tempHash << 7 +
-                logger->maxLevel;
-
-        PKIX_HASHCODE(logger->logComponent, &tempHash, plContext,
-                "PKIX_PL_Object_Hashcode failed");
-
-        hash = hash << 7 + tempHash;
+        hash = ((((PKIX_UInt32) logger->callback + tempHash) << 7) +
+                logger->maxLevel << 7) + (PKIX_UInt32)logger->logComponent;
 
         *pHashcode = hash;
 
 cleanup:
 
         PKIX_RETURN(LOGGER);
 }
 
@@ -564,21 +541,17 @@ pkix_Logger_Duplicate(
         dupLogger->maxLevel = logger->maxLevel;
         
         PKIX_DUPLICATE
                     (logger->context,
                     &dupLogger->context,
                     plContext,
                     "PKIX_PL_Object_Duplicate failed");
 
-        PKIX_DUPLICATE
-                    (logger->logComponent,
-                    &dupLogger->logComponent,
-                    plContext,
-                    "PKIX_PL_Object_Duplicate failed");
+        dupLogger->logComponent = logger->logComponent;
 
         *pNewObject = (PKIX_PL_Object *) dupLogger;
 
 cleanup:
 
         if (PKIX_ERROR_RECEIVED){
                 PKIX_DECREF(dupLogger);
         }
@@ -639,17 +612,17 @@ PKIX_Logger_Create(
                     (PKIX_LOGGER_TYPE,
                     sizeof (PKIX_Logger),
                     (PKIX_PL_Object **)&logger,
                     plContext),
                     "Could not create Logger object");
 
         logger->callback = callback;
         logger->maxLevel = 0;
-        logger->logComponent = NULL;
+        logger->logComponent = (PKIX_ERRORNUM)NULL;
 
         PKIX_INCREF(loggerContext);
         logger->context = loggerContext;
 
         *pLogger = logger;
 
 cleanup:
 
@@ -732,42 +705,39 @@ cleanup:
 }
 
 /*
  * FUNCTION: PKIX_Logger_GetLoggingComponent (see comments in pkix_util.h)
  */
 PKIX_Error *
 PKIX_Logger_GetLoggingComponent(
         PKIX_Logger *logger,
-        PKIX_PL_String **pComponent,
+        PKIX_ERRORNUM *pComponent,
         void *plContext)
 {
         PKIX_ENTER(LOGGER, "PKIX_Logger_GetLoggingComponent");
         PKIX_NULLCHECK_TWO(logger, pComponent);
 
-        PKIX_INCREF(logger->logComponent);
         *pComponent = logger->logComponent;
 
         PKIX_RETURN(LOGGER);
 }
 
 /*
  * FUNCTION: PKIX_Logger_SetLoggingComponent (see comments in pkix_util.h)
  */
 PKIX_Error *
 PKIX_Logger_SetLoggingComponent(
         PKIX_Logger *logger,
-        PKIX_PL_String *component,
+        PKIX_ERRORNUM component,
         void *plContext)
 {
         PKIX_ENTER(LOGGER, "PKIX_Logger_SetLoggingComponent");
         PKIX_NULLCHECK_ONE(logger);
 
-        PKIX_DECREF(logger->logComponent);
-        PKIX_INCREF(component);
         logger->logComponent = component;
 
         PKIX_RETURN(LOGGER);
 }
 
 
 /*
  * Following PKIX_GetLoggers(), PKIX_SetLoggers() and PKIX_AddLogger() are
@@ -886,17 +856,17 @@ PKIX_SetLoggers(
         PKIX_UInt32 i, length;
 
         PKIX_ENTER(LOGGER, "PKIX_SetLoggers");
 
         PKIX_CHECK(PKIX_PL_MonitorLock_Enter(pkixLoggerLock, plContext),
                 "PKIX_PL_MonitorLock_Enter failed");
         locked = PKIX_TRUE;
 
-	/* Disable tracing, etc. to avoid recursion and deadlock */
+        /* Disable tracing, etc. to avoid recursion and deadlock */
         savedPkixLoggersDebugTrace = pkixLoggersDebugTrace;
         pkixLoggersDebugTrace = NULL;
         savedPkixLoggersErrors = pkixLoggersErrors;
         pkixLoggersErrors = NULL;
 
         /* discard any prior loggers */
         PKIX_DECREF(pkixLoggers);
         PKIX_DECREF(savedPkixLoggersErrors);
--- a/security/nss/lib/libpkix/pkix/util/pkix_logger.h
+++ b/security/nss/lib/libpkix/pkix/util/pkix_logger.h
@@ -53,25 +53,25 @@ extern "C" {
 extern PKIX_List *pkixLoggers;
 extern PKIX_List *pkixLoggersErrors;
 extern PKIX_List *pkixLoggersDebugTrace;
 
 struct PKIX_LoggerStruct {
         PKIX_Logger_LogCallback callback;
         PKIX_PL_Object *context;
         PKIX_UInt32 maxLevel;
-        PKIX_PL_String *logComponent;
+        PKIX_ERRORNUM logComponent;
 };
 
 PKIX_Error *
 pkix_Logger_Check(
         PKIX_List *pkixLoggersList,
         char *message,
         char *message2,
-        PKIX_UInt32 logComponent,
+        PKIX_ERRORNUM logComponent,
         PKIX_UInt32 maxLevel,
         void *plContext);
 
 /* see source file for function documentation */
 
 PKIX_Error *pkix_Logger_RegisterSelf(void *plContext);
 
 #ifdef __cplusplus