# Class CapyEventReporter Namespace: [CapyKit](CapyKit.md) Assembly: CapyKit.dll The CapyEventReporter class is responsible for managing event subscriptions and emissions within CapyKit. ```csharp public static class CapyEventReporter ``` #### Inheritance [object](https://learn.microsoft.com/dotnet/api/system.object) ← [CapyEventReporter](CapyKit.CapyEventReporter.md) #### Inherited Members [object.Equals\(object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)), [object.Equals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)), [object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring) #### Extension Methods [ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_) ## Remarks Because consumers of CapyKit may have varied ways of handling logging, the provides a way for subscribers to recieve events for various "events" within the library. These can be thought of as a logging solution for CapyKit. Consumers are free to treat these events however they see fit. ## Methods ### EmitEvent\(EventLevel, string, string, params object\[\]\) Emits an event with the given severity level, message, and method name. ```csharp public static void EmitEvent(EventLevel eventLevel, string message, string method = null, params object[] args) ``` #### Parameters `eventLevel` [EventLevel](CapyKit.EventLevel.md) The severity level of the event. `message` [string](https://learn.microsoft.com/dotnet/api/system.string) The message describing the reason for the event. String formatting for args is accepted. `method` [string](https://learn.microsoft.com/dotnet/api/system.string) (Optional) The name of the method where the event was raised. `args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[\] A variable-length parameters list containing arguments for formatting the message. #### Examples
CapyEventReporter.EmitEvent(EventLevel.Error, "Could not find the description for {0}.", args: new[] { enumeration });
#### Remarks In order to allow for efficient calling member access via , it is suggested that args is defined explicitly for formatted messages. #### See Also [CallerMemberNameAttribute](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callermembernameattribute) ### EmitEventOnce\(EventLevel, string, string, string, params object\[\]\) Emits an event with the given severity level, message, unique identifier, and method name one time. ```csharp public static void EmitEventOnce(EventLevel eventLevel, string message, string uniqueIdentifier, string method = null, params object[] args) ``` #### Parameters `eventLevel` [EventLevel](CapyKit.EventLevel.md) The severity level of the event. `message` [string](https://learn.microsoft.com/dotnet/api/system.string) The message describing the reason for the event. String formatting for args is accepted. `uniqueIdentifier` [string](https://learn.microsoft.com/dotnet/api/system.string) A unique identifier for the event emission. `method` [string](https://learn.microsoft.com/dotnet/api/system.string) (Optional) The name of the method where the event was raised. `args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[\] A variable-length parameters list containing arguments for formatting the message. #### Remarks This method is similar to EmitEvent(EventLevel, string, string, string, object[]) , but requires a unique identifier (such as a ) to prevent duplicate emissions. #### See Also [CallerMemberNameAttribute](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callermembernameattribute), [Guid](https://learn.microsoft.com/dotnet/api/system.guid) ### Subscribe\(CapyEventHandler, EventLevel, string\) Subscribes the specified event handler to the event with the given subscription level and origin. ```csharp public static void Subscribe(CapyEventHandler callback, EventLevel subscriptionLevel, string origin = null) ``` #### Parameters `callback` [CapyEventHandler](CapyKit.CapyEventHandler.md) The event handler to subscribe. `subscriptionLevel` [EventLevel](CapyKit.EventLevel.md) The severity level of the event to subscribe to. `origin` [string](https://learn.microsoft.com/dotnet/api/system.string) (Optional) The name of the method or class where the subscription is made. #### Remarks If there is no existing list for the given subscription level, a new list is created and added to the dictionary. ### Unsubscribe\(CapyEventHandler, string\) Unsubscribes the specified event handler from the event with the given origin. ```csharp public static void Unsubscribe(CapyEventHandler callback, string origin) ``` #### Parameters `callback` [CapyEventHandler](CapyKit.CapyEventHandler.md) The event handler to unsubscribe. `origin` [string](https://learn.microsoft.com/dotnet/api/system.string) The name of the method or class where the subscription was made.