Exemple #1
0
VOID
MonCloseEventLog(
   )
/*++

Routine Description:

   Closes the handle to the event logger is this is the last caller.

Arguments:

   None

Return Value:

   None

--*/
{
   if (hEventLog != NULL) {

      dwLogUsers--;

      if (dwLogUsers <= 0) {

	 REPORT_INFORMATION(UTIL_CLOSING_LOG, LOG_DEBUG);

	 DeregisterEventSource(hEventLog);

      }
   }
} // end MonCloseEventLog
Exemple #2
0
VOID
pfCloseEventLog (
)
/*++

Routine Description:

      Closes the handle to the event logger if this is the last caller

Arguments:

      None

Return Value:

      None

--*/
{
    if (hEventLog != NULL) {
        dwLogUsers--;         /* decrement usage */
        if (dwLogUsers <= 0) {    /* and if we're the last, then close up log */
            REPORT_INFORMATION (PFUTIL_CLOSING_LOG, LOG_DEBUG);
            DeregisterEventSource (hEventLog);
        }
    }
}
Exemple #3
0
HANDLE MonOpenEventLog ()
/*++
Routine Description:

    Reads the level of event logging from the registry and opens the
    channel to the event logger for subsequent event log entries.

Arguments:
        None

Return Value:
        Handle to the event log for reporting events.
        NULL if open not successful.
--*/
{
    HKEY hAppKey;
    TCHAR LogLevelKeyName[] = "SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\PerfLib";
    TCHAR LogLevelValueName[] = "EventLogLevel";
    LONG lStatus;
    DWORD dwLogLevel;
    DWORD dwValueType;
    DWORD dwValueSize;

    // if global value of the logging level not initialized or is disabled,
    //  check the registry to see if it should be updated.

    if (!MESSAGE_LEVEL) {
        lStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
                               LogLevelKeyName,
                               0,
                               KEY_READ,
                               &hAppKey);
        dwValueSize = sizeof (dwLogLevel);
        if (lStatus == ERROR_SUCCESS) {
            lStatus = RegQueryValueEx (hAppKey,
                               LogLevelValueName,
                               (LPDWORD)NULL,
                               &dwValueType,
                               (LPBYTE)&dwLogLevel,
                               &dwValueSize);
            if (lStatus == ERROR_SUCCESS) {
               MESSAGE_LEVEL = dwLogLevel;
            }
            else {
               MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT;
            }
            RegCloseKey (hAppKey);
        }
        else {
            MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT;
        }
    }
    if (hEventLog == NULL) {
        hEventLog = RegisterEventSource (
            (LPTSTR)NULL,            // Use Local Machine
            APP_NAME);               // event log app name to find in registry
         if (hEventLog != NULL) {
            REPORT_INFORMATION (UTIL_LOG_OPEN, LOG_DEBUG);
         }
    }
    if (hEventLog != NULL) {
         dwLogUsers++;           // increment count of perfctr log users
    }
    return (hEventLog);
}
Exemple #4
0
HANDLE
MonOpenEventLog (
   )
/*++

Routine Description:

   Reads the level of event logging from the registry and opesn the channel
   to the event logger for subsequent event log entries.

Arguments:

   None

Return Value:

   Handle to the event LOG for reporting events

Revision History:


--*/
{
   HKEY		hAppKey;
   TCHAR 	LogLevelKeyName[] = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib";
   TCHAR 	LogLevelValueName[] = "EventLogLevel";
   LONG		lStatus;
   DWORD	dwLogLevel;
   DWORD	dwValueType;
   DWORD	dwValueSize;

   //
   // if global value of the logging level not initialized or disabled
   //

   if (!MESSAGE_LEVEL) {

      lStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
			     LogLevelKeyName,
			     0,
			     KEY_READ,
			     &hAppKey);

      dwValueSize = sizeof(dwLogLevel);

      if (lStatus == ERROR_SUCCESS) {

	 lStatus = RegQueryValueEx(hAppKey,
			           LogLevelValueName,
				   (LPDWORD)NULL,
				   &dwValueType,
				   (LPBYTE)&dwLogLevel,
				   &dwValueSize);

         if (lStatus == ERROR_SUCCESS) {
	    MESSAGE_LEVEL = dwLogLevel;
	 } else {
	    MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT;
	 }

	 RegCloseKey(hAppKey);

      } else {

	 MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT;

      }

   }

   if (hEventLog == NULL) {

      hEventLog = RegisterEventSource(
   	 (LPTSTR)NULL,
	 APP_NAME);

      if (hEventLog != NULL) {

	 REPORT_INFORMATION (UTIL_LOG_OPEN, LOG_DEBUG);

      }

   }

   if (hEventLog != NULL) {

      dwLogUsers++;

   }

   return (hEventLog);

} // end MonOpenEventLog