'Declaration
Public Event LogEntry As LogEntryEventHandler
'Usage
Dim instance As EasyUAClientConfiguration Dim handler As LogEntryEventHandler AddHandler instance.LogEntry, handler
public event LogEntryEventHandler LogEntry
public: event LogEntryEventHandler^ LogEntry
Event Data
The event handler receives an argument of type LogEntryEventArgs containing data related to this event. The following LogEntryEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Category | The application-specific subcategory associated with the message. |
DefaultTimestamp | Default value of the Timestamp property. |
EntryType | Entry type. One of the LogEntryType values. |
EventId | The application-specific identifier for the event. |
Message | The message text. |
RawData | An array of bytes that holds the binary data associated with the entry. |
Source | The name of the event source. |
Timestamp | Date and time of the log entry message. In UTC. |
TimestampDouble | Date and time of the log entry message. In UTC, as double-precision floating-point number that contains an OLE Automation date. |
TimestampLocal | Date and time of the log entry message. In local time. |
TimestampLocalDouble | Date and time of the log entry message. In local time, as double-precision floating-point number that contains an OLE Automation date. |
Example
// This example demonstrates the loggable entries originating in the OPC-UA client engine and the EasyUAClient component. #include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files #include <atlcom.h> #include "LogEntry.h" namespace _EasyUAClientConfiguration { // CEasyUAClientConfigurationEvents class CEasyUAClientConfigurationEvents : public IDispEventImpl<1, CEasyUAClientConfigurationEvents> { public: BEGIN_SINK_MAP(CEasyUAClientConfigurationEvents) // Event handlers must have the __stdcall calling convention SINK_ENTRY(1, 1 /*DISPID_EASYUACLIENTCONFIGURATIONEVENTS_LOGENTRY*/, &CEasyUAClientConfigurationEvents::LogEntry) END_SINK_MAP() public: // Event handler for the LogEntry event. It simply prints out the event. STDMETHOD(LogEntry)(VARIANT varSender, _LogEntryEventArgs* pEventArgs) { _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(pEventArgs->ToString)); return S_OK; } }; void LogEntry::Main() { // Initialize the COM library CoInitializeEx(NULL, COINIT_MULTITHREADED); { // The configuration object allows access to static behavior - here, the shared LogEntry event. _EasyUAClientConfigurationPtr ClientConfigurationPtr(__uuidof(EasyUAClientConfiguration)); // Hook events CEasyUAClientConfigurationEvents* pClientConfigurationEvents = new CEasyUAClientConfigurationEvents(); AtlGetObjectSourceInterface(ClientConfigurationPtr, &pClientConfigurationEvents->m_libid, &pClientConfigurationEvents->m_iid, &pClientConfigurationEvents->m_wMajorVerNum, &pClientConfigurationEvents->m_wMinorVerNum); pClientConfigurationEvents->m_iid = _uuidof(DEasyUAClientConfigurationEvents); pClientConfigurationEvents->DispEventAdvise(ClientConfigurationPtr, &pClientConfigurationEvents->m_iid); // Do something - invoke an OPC read, to trigger some loggable entries. _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient)); ClientPtr->ReadValue(L"http://opcua.demo-this.com:51211/UA/SampleServer", L"nsu=http://test.org/UA/Data/;i=10853"); _tprintf(_T("Processing log entry events for 1 minute...\n")); Sleep(60*1000); // Unhook events pClientConfigurationEvents->DispEventUnadvise(ClientConfigurationPtr, &pClientConfigurationEvents->m_iid); } // Release all interface pointers BEFORE calling CoUninitialize() CoUninitialize(); } }
// This example demonstrates the loggable entries originating in the OPC-UA // client engine and the EasyUAClient component. type TClientConfigurationEventHandlers = class procedure OnLogEntry( Sender: TObject; sender0: OleVariant; eventArgs: _LogEntryEventArgs); end; // Event handler for the LogEntry event. It simply prints out the event. procedure TClientConfigurationEventHandlers.OnLogEntry( Sender: TObject; sender0: OleVariant; eventArgs: _LogEntryEventArgs); begin WriteLn(eventArgs.ToString); end; class procedure LogEntry.Main; var Client: EasyUAClient; EvsClientConfiguration: TEvsEasyUAClientConfiguration; ClientConfiguration: EasyUAClientConfiguration; ClientConfigurationEventHandlers: TClientConfigurationEventHandlers; Value: OleVariant; begin // The configuration object allows access to static behavior - here, the // shared LogEntry event. EvsClientConfiguration := TEvsEasyUAClientConfiguration.Create(nil); ClientConfiguration := EvsClientConfiguration.ComServer; ClientConfigurationEventHandlers := TClientConfigurationEventHandlers.Create; EvsClientConfiguration.OnLogEntry := @ClientConfigurationEventHandlers.OnLogEntry; // Do something - invoke an OPC read, to trigger some loggable entries. Client := CoEasyUAClient.Create; Value := Client.ReadValue( 'http://opcua.demo-this.com:51211/UA/SampleServer', 'nsu=http://test.org/UA/Data/;i=10853'); WriteLn('Processing log entry events for 1 minute...'); PumpSleep(60*1000); end;
// This example demonstrates the loggable entries originating in the OPC-UA // client engine and the EasyUAClient component. type TClientConfigurationEventHandlers130 = class procedure OnLogEntry( ASender: TObject; sender: OleVariant; const eventArgs: _LogEntryEventArgs); end; // Event handler for the LogEntry event. It simply prints out the event. procedure TClientConfigurationEventHandlers130.OnLogEntry( ASender: TObject; sender: OleVariant; const eventArgs: _LogEntryEventArgs); begin WriteLn(eventArgs.ToString); end; class procedure LogEntry.Main; var Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient; ClientConfiguration: TEasyUAClientConfiguration; ClientConfigurationEventHandlers: TClientConfigurationEventHandlers130; Value: OleVariant; begin // The configuration object allows access to static behavior - here, the // shared LogEntry event. ClientConfiguration := TEasyUAClientConfiguration.Create(nil); ClientConfigurationEventHandlers := TClientConfigurationEventHandlers130.Create; ClientConfiguration.OnLogEntry := ClientConfigurationEventHandlers.OnLogEntry; ClientConfiguration.Connect; // Do something - invoke an OPC read, to trigger some loggable entries. Client := CoEasyUAClient.Create; try Value := Client.ReadValue( 'http://opcua.demo-this.com:51211/UA/SampleServer', 'nsu=http://test.org/UA/Data/;i=10853'); except on E: EOleException do begin WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message])); //Exit; end; end; WriteLn('Processing log entry events for 1 minute...'); PumpSleep(60*1000); WriteLn('Finished.'); FreeAndNil(ClientConfiguration); FreeAndNil(ClientConfigurationEventHandlers); end;
// This example demonstrates the loggable entries originating in the OPC-UA client engine and the EasyUAClient component. class ClientConfigurationEvents { // Event handler for the LogEntry event. It simply prints out the event. function LogEntry($Sender, $E) { printf("%s\n", $E); } } // The configuration object allows access to static behavior - here, the shared LogEntry event. $ClientConfiguration = new COM("OpcLabs.EasyOpc.UA.EasyUAClientConfiguration"); $ClientConfigurationEvents = new ClientConfigurationEvents(); com_event_sink($ClientConfiguration, $ClientConfigurationEvents, "DEasyUAClientConfigurationEvents"); // Do something - invoke an OPC read, to trigger some loggable entries. $Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient"); try { $value = $Client->ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853"); } catch (com_exception $e) { printf("*** Failure: %s\n", $e->getMessage()); Exit(); } printf("Processing log entry events for 1 minute..."); $startTime = time(); do { com_message_pump(1000); } while (time() < $startTime + 60);
REM This example demonstrates the loggable entries originating in the OPC-UA client engine and the EasyUAClient component. ' The configuration object allows access to static behavior - here, the shared LogEntry event. 'Public WithEvents ClientConfiguration1 As EasyUAClientConfiguration Private Sub LogEntry_Main_Command_Click() OutputText = "" Set ClientConfiguration1 = New EasyUAClientConfiguration ' Do something - invoke an OPC read, to trigger some loggable entries. Dim Client As New EasyUAClient On Error Resume Next Dim value As Variant value = Client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853") If Err.Number <> 0 Then OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf Exit Sub End If On Error GoTo 0 OutputText = OutputText & "Processing log entry events for 1 minute..." & vbCrLf Pause 60000 Set ClientConfiguration1 = Nothing OutputText = OutputText & "Finished..." & vbCrLf End Sub ' Event handler for the LogEntry event. It simply prints out the event. Private Sub ClientConfiguration1_LogEntry(ByVal sender As Variant, ByVal eventArgs As OpcLabs_BaseLib.LogEntryEventArgs) OutputText = OutputText & eventArgs & vbCrLf End Sub
Rem This example demonstrates the loggable entries originating in the OPC-UA client engine and the EasyUAClient component. Option Explicit ' The configuration object allows access to static behavior - here, the shared LogEntry event. Dim ClientConfiguration: Set ClientConfiguration = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClientConfiguration") WScript.ConnectObject ClientConfiguration, "ClientConfiguration_" ' Do something - invoke an OPC read, to trigger some loggable entries. Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient") On Error Resume Next Dim value: value = Client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853") If Err.Number <> 0 Then WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description WScript.Quit End If On Error Goto 0 WScript.Echo "Processing log entry events for 1 minute..." WScript.Sleep 60*1000 ' Event handler for the LogEntry event. It simply prints out the event. Sub ClientConfiguration_LogEntry(Sender, e) WScript.Echo e End Sub
Requirements
Target Platforms: .NET Framework: Windows 10, Windows Server 2012; .NET Core: Linux, macOS, Microsoft Windows
See Also