PLOG_EVENT_ROUTINE回呼函式 (resapi.h)

記錄叢集記錄檔中的事件。 PLOG_EVENT_ROUTINE類型會定義此函式的指標。

語法

PLOG_EVENT_ROUTINE PlogEventRoutine;

VOID PlogEventRoutine(
  [in] RESOURCE_HANDLE ResourceHandle,
  [in] LOG_LEVEL LogLevel,
  [in] LPCWSTR FormatString,
       ... unnamedParam4
)
{...}

參數

[in] ResourceHandle

處理識別記錄事件的資源。 ResourceHandle 的值應該是在此資源的 Open 呼叫期間傳入的句柄。

[in] LogLevel

LOG_LEVEL列舉所列舉的值,表示事件的記錄層級,且僅供資訊使用。 下列有效值會依最小到最嚴重的順序顯示。

LOG_INFORMATION (0)

事件為參考。

LOG_WARNING (1)

事件會報告可能發生的失敗,但不確定是否真的發生失敗。

LOG_ERROR (2)

此事件會影響單一元件,但其他元件不會受到影響,而且 節點 其餘部分的完整性不會遭到入侵。

LOG_SEVERE (3)

此事件報告嚴重失敗,會影響多個元件,或整個系統的完整性遭到入侵或認為遭到入侵。

[in] FormatString

以 Null 結束的 Unicode 字串,其中包含要記錄的資訊。 此字串的格式必須與傳遞給 FormatMessage 函式的格式相同。

unnamedParam4

傳回值

無

備註

LogEvent 回呼函式是由資源監視器所實作,並由資源 DLL 呼叫,以向叢集記錄報告事件和錯誤。 資源 DLL 會接收 LogEvent 參數中 LogEvent 回呼函式的指標,指向其 Startup 進入點函式。

LogEvent 不會將專案寫入事件記錄檔。 若要報告事件記錄檔中的事件,資源 DLL 必須呼叫 ReportEvent 函式。

記錄訊息的格式如下所示:

ResourceTypeName ResourceName: message

ResourceTypeName 是 資源類型,例如「一般應用程式」。 特定資源名稱是特定資源的使用者易記名稱,而訊息是由資源 DLL 傳遞至資源監視器的訊息。

記錄專案大小限制為 500 個字元。

範例

下列範例是以叢集資源類型精靈所產生的程式代碼為基礎。 如需其他範例,請參閱 資源 DLL 範例。

//  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 );

規格需求

需求 值
最低支援的用戶端 都不支援
最低支援的伺服器 Windows Server 2008 Enterprise、Windows Server 2008 Datacenter
目標平台 Windows
標頭 resapi.h

另請參閱

LOG_LEVEL

開啟

ReportEvent

資源 DLL 回呼函式

啟動