Export (0) Print
Expand All

LogEvent callback function

Records an event in the cluster log. The PLOG_EVENT_ROUTINE type defines a pointer to this function.

Syntax


VOID WINAPI LogEvent(
  _In_  RESOURCE_HANDLE ResourceHandle,
  _In_  LOG_LEVEL LogLevel,
  _In_  LPCWSTR FormatString,
   ...
);

typedef VOID (WINAPI *PLOG_EVENT_ROUTINE)(
    _In_  RESOURCE_HANDLE ResourceHandle,
    _In_  LOG_LEVEL LogLevel,
    _In_  LPCWSTR FormatString,
     ...
);

Parameters

ResourceHandle [in]

Handle identifying the resource recording the event. The value for ResourceHandle should be the handle passed in during the Open call for this resource.

LogLevel [in]

Value enumerated by the LOG_LEVEL enumeration that represents the log level of the event and that is for information only. The following valid values are shown in order from least to most severe.

LogLevel valueMeaning
LOG_INFORMATION
0

The event is informational.

LOG_WARNING
1

The event is reporting a failure that might have happened, but it is uncertain whether a failure really did occur.

LOG_ERROR
2

The event affects a single component, but other components are not affected and the integrity of the rest of the node is not compromised.

LOG_SEVERE
3

The event is reporting a severe failure that affects multiple components, or the integrity of the entire system is compromised or believed to be compromised.

 

FormatString [in]

Null-terminated Unicode string that includes the information to be recorded. This string must be in the same format as that passed to the FormatMessage function.

...

Arguments to be passed to FormatMessage along with FormatString. Any number of arguments may be specified as long as they work with FormatString to satisfy the syntax requirements of FormatMessage. Arguments must be separated by commas.

Return value

This function has no return values.

Remarks

The LogEvent callback function is implemented by the Resource Monitor and is called by a resource DLL to report events and errors to the cluster log. Resource DLLs receive a pointer to the LogEvent callback function in the LogEvent parameter to their Startup entry-point function.

LogEvent does not write entries to the event log. To report events in the event log, a resource DLL must call the ReportEvent function.

The format of the logged message appears as follows:

ResourceTypeName ResourceName: message

ResourceTypeName is the resource type, such as "Generic Application". The specific resource name is the user-friendly name for the specific resource, and message is the message delivered by the resource DLL to the Resource Monitor.

The log entry size is limited to 500 characters.

Examples

The following example is based on code generated by the Cluster Resource Type Wizard. For additional examples, see Resource DLL Examples.

//  The following parameters are assumed to be already defined:
//  g_pfnLogEvent   Stores the address of the LogEvent callback
//                  function passed to the DLL in the
//                  Startup entry point.
//  pResourceEntry  Stores resource instance data.
//  MY_SVCNAME      Stores the name of a service.
//  nStatus         Result

//  Log the fact that an attempt to start a service has failed.

//  Basic message
    (g_pfnLogEvent)( pResourceEntry->hResourceHandle,
                     LOG_ERROR,
                     L"Failed to start the specified service.\n" );

//  Message w/string argument
    (g_pfnLogEvent)( pResourceEntry->hResourceHandle,
                     LOG_ERROR,
                     L"OnlineThread: Failed to start the '%1' service.\n",
                     MY_SVCNAME );

//  Message w/multiple arguments
    (g_pfnLogEvent)( pResourceEntry->hResourceHandle,
                     LOG_ERROR,
                     L"OnlineThread: Failed to start the '%1' service. Error: %2!u!.\n",
                     MY_SVCNAME,
                     nStatus );

Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2003 Enterprise, Windows Server 2003 Datacenter

Header

ResApi.h

See also

Resource DLL Callback Functions
Open
ReportEvent
Startup
LOG_LEVEL

 

 

Show:
© 2014 Microsoft