/* ======================================================================== * Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ using System; using System.Diagnostics.Tracing; namespace Opc.Ua.Client { /// /// EventSource for client. /// public static partial class CoreClientUtils { /// /// The EventSource log interface. /// internal static OpcUaClientEventSource EventLog { get; } = new OpcUaClientEventSource(); } /// /// Event source for high performance logging. /// [EventSource(Name = "OPC-UA-Client", Guid = "8CFA469E-18C6-480F-9B74-B005DACDE3D3")] internal class OpcUaClientEventSource : EventSource { internal const int SubscriptionStateId = 1; internal const int NotificationId = SubscriptionStateId + 1; internal const int NotificationReceivedId = NotificationId + 1; internal const int PublishStartId = NotificationReceivedId + 1; internal const int PublishStopId = PublishStartId + 1; /// /// The state of the client subscription. /// [Event( SubscriptionStateId, Message = "Subscription {0}, Id={1}, LastNotificationTime={2:HH:mm:ss}, " + "GoodPublishRequestCount={3}, PublishingInterval={4}, KeepAliveCount={5}, " + "PublishingEnabled={6}, MonitoredItemCount={7}", Level = EventLevel.Verbose)] public void SubscriptionState( string context, uint id, DateTime lastNotificationTime, int goodPublishRequestCount, double currentPublishingInterval, uint currentKeepAliveCount, bool currentPublishingEnabled, uint monitoredItemCount) { WriteEvent( SubscriptionStateId, context, id, lastNotificationTime, goodPublishRequestCount, currentPublishingInterval, currentKeepAliveCount, currentPublishingEnabled, monitoredItemCount); } /// /// The notification message. Called internally to convert wrapped value. /// [Event( NotificationId, Message = "Notification: ClientHandle={0}, Value={1}", Level = EventLevel.Verbose)] public void Notification(int clientHandle, string value) { if (IsEnabled()) { WriteEvent(NotificationId, clientHandle, value); } } /// /// A notification received in Publish complete. /// [Event( NotificationReceivedId, Message = "NOTIFICATION RECEIVED: SubId={0}, SeqNo={1}", Level = EventLevel.Verbose)] public void NotificationReceived(int subscriptionId, int sequenceNumber) { if (IsEnabled()) { WriteEvent(NotificationReceivedId, subscriptionId, sequenceNumber); } } /// /// A Publish begin received. /// [Event( PublishStartId, Message = "PUBLISH #{0} SENT", Level = EventLevel.Verbose)] public void PublishStart(int requestHandle) { if (IsEnabled()) { WriteEvent(PublishStartId, requestHandle); } } /// /// A Publish complete received. /// [Event( PublishStopId, Message = "PUBLISH #{0} RECEIVED", Level = EventLevel.Verbose)] public void PublishStop(int requestHandle) { if (IsEnabled()) { WriteEvent(PublishStopId, requestHandle); } } } }